Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
124 views20 pages

Lesson 3 MRSM

This document provides an overview of lessons from an Arduino mobile robotics workshop. It includes 3 modules - LED, button, and IR sensor. Module 1 covers blinking an LED and includes sample Arduino code. Module 2 introduces a push button with LED. Module 3 demonstrates a running light controlled by an IR sensor, with code to read the sensor and control the LED. The Arduino code basics section explains that programs have setup and loop sections, with setup assigning ports and loop controlling ongoing operations.

Uploaded by

matin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
124 views20 pages

Lesson 3 MRSM

This document provides an overview of lessons from an Arduino mobile robotics workshop. It includes 3 modules - LED, button, and IR sensor. Module 1 covers blinking an LED and includes sample Arduino code. Module 2 introduces a push button with LED. Module 3 demonstrates a running light controlled by an IR sensor, with code to read the sensor and control the LED. The Arduino code basics section explains that programs have setup and loop sections, with setup assigning ports and loop controlling ongoing operations.

Uploaded by

matin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

ARDUINO – MOBILE ROBOTICS

WORKSHOP

#TrailblazingTheFutureOfConnectedObjects#
LESSON 3

#TrailblazingTheFutureOfConnectedObjects#
Module 1 - LED

#TrailblazingTheFutureOfConnectedObjects#

8
Let Do Practical

Module 1 : Blink LED


10
Let Do Practical
Exercise 1 – LED BLINKING

HIGH
LOW
Let Do Practical
Continued…Exercise 1 – LED BLINKING

/ Project 1 - LED

Flasher

/ int ledPin = 10;


void setup() {
pinMode(ledPin, OUTPUT);
}

void loop() { 
LOW
digitalWrite(ledPin, HIGH);


delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}

HIGH
LOW
Arduino Code Basics
Arduino programs run on two basic sections:

void setup() {

//setup motors, sensors etc

}
void loop() {

// get information from sensors


// send commands to motors

}
SETUP
• The setup section is used for assigning input
and outputs (Examples: motors, LED’s, sensors
etc) to ports on the Arduino
• It also specifies whether the device is OUTPUT
or INPUT
• To do this we use the command “pinMode”

14 14
SETUP
void setup() {
port #

pinMode(9, OUTPUT);
Input or Output
}

http://www.arduino.cc/en/Reference/HomePage
LOOP
void loop() { Port # from setup

digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(1000);
Turn the LED on
or off
} Wait for 1 second
or 1000 milliseconds

16
Let Do Practical
Exercise 2 – LED RUNNING LIGHT
Module 2 - BUTTON

#TrailblazingTheFutureOfConnectedObjects#
18
Let Do Practical

Module 2 : Push Button with LED


Let Do Practical

Button Schematic
Let Do Practical

Exercise 1 – 1 PUSH BUTTON and 3 LED

Refer page 10 your module


Module 3 – IR Sensor

22
Let Do Practical
Module 3 : Running Light with IR Sensor

PragmaticEdu Media
Let Do Practical
Continued…Running Light with IR Sensor

const int SensorPin = 2; // set pin numbers for IR sensor pin


const int ledPin = 13; // the number of the LED pin
int SensorState = 0; // variable for reading the pushbutton status

void setup()
{
pinMode(ledPin, OUTPUT); // initialize the LED pin as an output
pinMode(SensorPin , INPUT); // initialize the IR sensor pin as an input
}

void loop()
{
SensorState = digitalRead(SensorPin); // read the state of the IR sensor value
if (SensorState == HIGH) // check if the IR sensor is pressed
{ // if it is, the IR sensor is HIGH
digitalWrite(ledPin, HIGH); // turn LED on
}
else
{
digitalWrite(ledPin, LOW); // turn LED off:
}
}

PragmaticEdu Media
ARDUINO – MOBILE ROBOTICS WORKSHOP

You might also like