SlideShare a Scribd company logo
Welcome
to Robotics
Lab Rules
Uniform
Attendance
Class Schedule
Smart Parking
Assistant
Engr. Hassan Mehmood Khan
Robotics Lab Incharge
List of Components
• Arduino UNO
• Breadboard
• Ultrasonic sensor
• LED Traffic Light Module
• Connecting Wires
• Programming Cable
• 9V Battery
• Connecting wires and clips
Arduino UNO
Digital I/O pins – input and output
pins (0 -13) of which 6 of them (3, 5, 6,
9, 10 and 11) also provide PWM (Pulse
Width Modulated) output by using the
analogWrite() function.
Pins (0 (RX) and 1 (TX)) are also used to
transmit and receive serial data.
The microcontroller development
board that will be at the heart of your
projects. It’s a simple computer, but
one that has no way for you to
interact with it yet. You will be
building the circuits and interfaces for
interaction, and telling the
microcontroller how to interface with
other components.
Digital IO
• The digital inputs and outputs (digital I/O) on
the Arduino are what allow you to connect
sensors, actuators, and other ICs to the
Arduino .
• Learning how to use the inputs and outputs will
allow you to use the Arduino to do some really
useful things, such as reading switch inputs,
lighting indicators, and controlling relay
outputs.
• Unlike analog signals, which may take on any
value within a range of values, digital signals
have two distinct values: HIGH (1) or LOW (0).
You use digital signals in situationswhere the
input or output will have one of those two
values. For example, one way that you might
use a digital signal is to turn an LED on or off.
Breadboard
A board on which you can build electronic circuits.
It’s like a patch panel, with rows of holes that allow
you to connect wires and components together.
Versions that require soldering are available, as well
as the solder-less type used here.
Ultrasonic Distance Sensor
RGB LED Module
•Size: 56 * 21 * 11mm
•Color: red, yellow green
•LED: 5mm * 3
•Brightness: Normal
brightness
•Voltage: 5V
•Input: Digital signal output
•Interface: common
cathode red yellow-green
control
Traffic Light Project
Wiring Diagram
Functions
• The Arduino functions
associated with digital
signals that we will be
using are:
• pinMode()
• digitalRead()
• digitalWrite()
pinMode (pin_number, mode)
Because the Arduino digital I/O pins can be used for
either input or output, you should first configure the
pins you intend to use for digital I/O with this
function. pin is the number of the pin you wish to
configure. mode must be one of three values: INPUT,
OUTPUT. (third value we will not discuss here)
digitalWrite(pin_number,value)
This function writes a digital value to a
pin. pin specifies which Arduino pin the digital value
will be written to, and value is the digital value to which
the pin is set. Value must be either HIGH or LOW.
digitalRead(pin_number)
This function reads a digital value from a pin. pin is the
number of the digital I/O pin you want to read. This
function returns one of two values: HIGH or LOW.
Programming
int red = 2;
int yellow = 3;
int green = 4;
void setup(){
pinMode(red, OUTPUT);
pinMode(yellow,
OUTPUT);
pinMode(green, OUTPUT);
}
void loop(){
// green off, yellow on for 3 seconds
digitalWrite(green, LOW);
digitalWrite(yellow, HIGH);
delay(3000);
// turn off yellow, then turn red on for 5
seconds
digitalWrite(yellow, LOW);
digitalWrite(red, HIGH);
delay(5000);
// red and yellow on for 2 seconds (red is
already on though)
digitalWrite(yellow, HIGH);
delay(2000);
// turn off red and yellow, then turn on green
digitalWrite(yellow, LOW);
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
delay(3000);
Programming
• The program consists of four distinct steps:
• Green on, yellow off
• Yellow off, red on
• Yellow on, red on
• Green on, red off, yellow off
• These four steps replicate the process used in real traffic
lights. For each step, the code is very similar. The
appropriate LED gets turned on or off using digitalWrite.
This is an Arduino function used to set output pins to HIGH
(for on), or LOW (for off).
Circuit Diagram
Programming
int trigPin = 2; // Trigger
int echoPin = 3; // Echo
int LED_Red = 10; // Red LED
int LED_Yellow = 8; // Yellow LED
int LED_Green = 9; // Green LED
long duration, cm, inches;
void setup()
{
//Serial Port begin
Serial.begin (9600);
//Define inputs and outputs
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(LED_Red, OUTPUT);
pinMode(LED_Yellow, OUTPUT);
pinMode(LED_Green, OUTPUT);
digitalWrite(LED_Red, LOW);
digitalWrite(LED_Yellow, LOW);
digitalWrite(LED_Green, LOW);
}
Programming
void loop() {
// The sensor is triggered by a HIGH
pulse of 10 or more microseconds.
// Give a short LOW pulse beforehand
to ensure a clean HIGH pulse:
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Read the signal from the sensor: a
HIGH pulse whose duration is the time
(in microseconds) from the sending of
the ping to the reception of its echo off
of an object.
duration = pulseIn(echoPin, HIGH);
// Convert the time into a distance
cm = (duration/2) / 29.1; // Divide
by 29.1 or multiply by 0.0343
inches = (duration/2) / 74; // Divide
by 74 or multiply by 0.0135
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
if(cm<10)
{
digitalWrite(LED_Red, HIGH);
digitalWrite(LED_Yellow, LOW);
digitalWrite(LED_Green, LOW);
}
if((cm<20) && (cm>10))
{
digitalWrite(LED_Red, LOW);
digitalWrite(LED_Yellow, HIGH);
digitalWrite(LED_Green, LOW);
}
if(cm>20)
{
digitalWrite(LED_Red, LOW);
digitalWrite(LED_Yellow, LOW);
digitalWrite(LED_Green, HIGH);
}
delay(250);
}
Simulation
THANK YOU

More Related Content

Similar to Lecture2- Smart Parking Assistant using Arduino (20)

PPT
arduino.ppt
sunilkumar652338
 
PPTX
Arduino
LetzkuLetz Castro
 
PPSX
Arduino اردوينو
salih mahmod
 
PPTX
Arduino.pptx
AadilKk
 
PPTX
Arduino Slides With Neopixels
sdcharle
 
PPTX
Arduino . .
dryazhinians
 
PPT
Introduction to Arduino - Basics programming
KishoreKumarKAsstPro
 
KEY
Intro to Arduino
Qtechknow
 
PPTX
Arduino_Beginner.pptx
shivagoud45
 
PPTX
Introduction to Arduino Microcontroller
Mujahid Hussain
 
PPTX
Introduction to the Arduino
Wingston
 
PDF
LinnStrument : the ultimate open-source hacker instrument
Geert Bevin
 
PPTX
Arduino board program for Mobile robotss
VSARAVANAKUMARHICETS
 
PDF
Arduino microcontroller ins and outs with pin diagram
ArifatunNesa
 
PDF
L6 Visual Output LED_7SEGMEN_LEDMATRIX upate.pdf
Indra Hermawan
 
PDF
L6 Visual Output LED_7SEGMEN_LEDMATRIX upate.pdf
Indra Hermawan
 
PPT
ArduinoSectionI-slides.ppt
Lam Hung
 
PDF
introductiontoarduino-111120102058-phpapp02.pdf
HebaEng
 
PPTX
Basics of arduino uno
Rahat Sood
 
PPTX
Fun with arduino
Ravikumar Tiwari
 
arduino.ppt
sunilkumar652338
 
Arduino اردوينو
salih mahmod
 
Arduino.pptx
AadilKk
 
Arduino Slides With Neopixels
sdcharle
 
Arduino . .
dryazhinians
 
Introduction to Arduino - Basics programming
KishoreKumarKAsstPro
 
Intro to Arduino
Qtechknow
 
Arduino_Beginner.pptx
shivagoud45
 
Introduction to Arduino Microcontroller
Mujahid Hussain
 
Introduction to the Arduino
Wingston
 
LinnStrument : the ultimate open-source hacker instrument
Geert Bevin
 
Arduino board program for Mobile robotss
VSARAVANAKUMARHICETS
 
Arduino microcontroller ins and outs with pin diagram
ArifatunNesa
 
L6 Visual Output LED_7SEGMEN_LEDMATRIX upate.pdf
Indra Hermawan
 
L6 Visual Output LED_7SEGMEN_LEDMATRIX upate.pdf
Indra Hermawan
 
ArduinoSectionI-slides.ppt
Lam Hung
 
introductiontoarduino-111120102058-phpapp02.pdf
HebaEng
 
Basics of arduino uno
Rahat Sood
 
Fun with arduino
Ravikumar Tiwari
 

Recently uploaded (20)

PDF
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
PPTX
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
PPTX
Server Side Web Development Unit 1 of Nodejs.pptx
sneha852132
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
PPTX
Day2 B2 Best.pptx
helenjenefa1
 
PPTX
Break Statement in Programming with 6 Real Examples
manojpoojary2004
 
PPTX
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
PPTX
MPMC_Module-2 xxxxxxxxxxxxxxxxxxxxx.pptx
ShivanshVaidya5
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PPTX
Green Building & Energy Conservation ppt
Sagar Sarangi
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
PPTX
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
DOC
MRRS Strength and Durability of Concrete
CivilMythili
 
PDF
monopile foundation seminar topic for civil engineering students
Ahina5
 
PPTX
artificial intelligence applications in Geomatics
NawrasShatnawi1
 
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
Server Side Web Development Unit 1 of Nodejs.pptx
sneha852132
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
Day2 B2 Best.pptx
helenjenefa1
 
Break Statement in Programming with 6 Real Examples
manojpoojary2004
 
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
MPMC_Module-2 xxxxxxxxxxxxxxxxxxxxx.pptx
ShivanshVaidya5
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
Green Building & Energy Conservation ppt
Sagar Sarangi
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
MRRS Strength and Durability of Concrete
CivilMythili
 
monopile foundation seminar topic for civil engineering students
Ahina5
 
artificial intelligence applications in Geomatics
NawrasShatnawi1
 
Ad

Lecture2- Smart Parking Assistant using Arduino

  • 3. Smart Parking Assistant Engr. Hassan Mehmood Khan Robotics Lab Incharge
  • 4. List of Components • Arduino UNO • Breadboard • Ultrasonic sensor • LED Traffic Light Module • Connecting Wires • Programming Cable • 9V Battery • Connecting wires and clips
  • 5. Arduino UNO Digital I/O pins – input and output pins (0 -13) of which 6 of them (3, 5, 6, 9, 10 and 11) also provide PWM (Pulse Width Modulated) output by using the analogWrite() function. Pins (0 (RX) and 1 (TX)) are also used to transmit and receive serial data. The microcontroller development board that will be at the heart of your projects. It’s a simple computer, but one that has no way for you to interact with it yet. You will be building the circuits and interfaces for interaction, and telling the microcontroller how to interface with other components.
  • 6. Digital IO • The digital inputs and outputs (digital I/O) on the Arduino are what allow you to connect sensors, actuators, and other ICs to the Arduino . • Learning how to use the inputs and outputs will allow you to use the Arduino to do some really useful things, such as reading switch inputs, lighting indicators, and controlling relay outputs. • Unlike analog signals, which may take on any value within a range of values, digital signals have two distinct values: HIGH (1) or LOW (0). You use digital signals in situationswhere the input or output will have one of those two values. For example, one way that you might use a digital signal is to turn an LED on or off.
  • 7. Breadboard A board on which you can build electronic circuits. It’s like a patch panel, with rows of holes that allow you to connect wires and components together. Versions that require soldering are available, as well as the solder-less type used here.
  • 9. RGB LED Module •Size: 56 * 21 * 11mm •Color: red, yellow green •LED: 5mm * 3 •Brightness: Normal brightness •Voltage: 5V •Input: Digital signal output •Interface: common cathode red yellow-green control
  • 12. Functions • The Arduino functions associated with digital signals that we will be using are: • pinMode() • digitalRead() • digitalWrite() pinMode (pin_number, mode) Because the Arduino digital I/O pins can be used for either input or output, you should first configure the pins you intend to use for digital I/O with this function. pin is the number of the pin you wish to configure. mode must be one of three values: INPUT, OUTPUT. (third value we will not discuss here) digitalWrite(pin_number,value) This function writes a digital value to a pin. pin specifies which Arduino pin the digital value will be written to, and value is the digital value to which the pin is set. Value must be either HIGH or LOW. digitalRead(pin_number) This function reads a digital value from a pin. pin is the number of the digital I/O pin you want to read. This function returns one of two values: HIGH or LOW.
  • 13. Programming int red = 2; int yellow = 3; int green = 4; void setup(){ pinMode(red, OUTPUT); pinMode(yellow, OUTPUT); pinMode(green, OUTPUT); } void loop(){ // green off, yellow on for 3 seconds digitalWrite(green, LOW); digitalWrite(yellow, HIGH); delay(3000); // turn off yellow, then turn red on for 5 seconds digitalWrite(yellow, LOW); digitalWrite(red, HIGH); delay(5000); // red and yellow on for 2 seconds (red is already on though) digitalWrite(yellow, HIGH); delay(2000); // turn off red and yellow, then turn on green digitalWrite(yellow, LOW); digitalWrite(red, LOW); digitalWrite(green, HIGH); delay(3000);
  • 14. Programming • The program consists of four distinct steps: • Green on, yellow off • Yellow off, red on • Yellow on, red on • Green on, red off, yellow off • These four steps replicate the process used in real traffic lights. For each step, the code is very similar. The appropriate LED gets turned on or off using digitalWrite. This is an Arduino function used to set output pins to HIGH (for on), or LOW (for off).
  • 16. Programming int trigPin = 2; // Trigger int echoPin = 3; // Echo int LED_Red = 10; // Red LED int LED_Yellow = 8; // Yellow LED int LED_Green = 9; // Green LED long duration, cm, inches; void setup() { //Serial Port begin Serial.begin (9600); //Define inputs and outputs pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(LED_Red, OUTPUT); pinMode(LED_Yellow, OUTPUT); pinMode(LED_Green, OUTPUT); digitalWrite(LED_Red, LOW); digitalWrite(LED_Yellow, LOW); digitalWrite(LED_Green, LOW); }
  • 17. Programming void loop() { // The sensor is triggered by a HIGH pulse of 10 or more microseconds. // Give a short LOW pulse beforehand to ensure a clean HIGH pulse: digitalWrite(trigPin, LOW); delayMicroseconds(5); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Read the signal from the sensor: a HIGH pulse whose duration is the time (in microseconds) from the sending of the ping to the reception of its echo off of an object. duration = pulseIn(echoPin, HIGH); // Convert the time into a distance cm = (duration/2) / 29.1; // Divide by 29.1 or multiply by 0.0343 inches = (duration/2) / 74; // Divide by 74 or multiply by 0.0135 Serial.print(inches); Serial.print("in, "); Serial.print(cm); Serial.print("cm"); Serial.println(); if(cm<10) { digitalWrite(LED_Red, HIGH); digitalWrite(LED_Yellow, LOW); digitalWrite(LED_Green, LOW); } if((cm<20) && (cm>10)) { digitalWrite(LED_Red, LOW); digitalWrite(LED_Yellow, HIGH); digitalWrite(LED_Green, LOW); } if(cm>20) { digitalWrite(LED_Red, LOW); digitalWrite(LED_Yellow, LOW); digitalWrite(LED_Green, HIGH); } delay(250); }