0% found this document useful (0 votes)
29 views17 pages

Interactive Traffic Light Project 240120 210417

The document describes the steps to build an interactive traffic light project using an Arduino board. It starts with basic traffic lights that cycle between green, yellow and red. It is then expanded to include pedestrian lights, a push button for pedestrians to request a walk signal, a motion sensor to detect pedestrians, an LCD display to show messages, and a temperature sensor to display the temperature. Each step provides the additional components needed and code modifications to integrate the new functionality. The full project creates an intelligent traffic light system that assists both drivers and pedestrians safely.
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)
29 views17 pages

Interactive Traffic Light Project 240120 210417

The document describes the steps to build an interactive traffic light project using an Arduino board. It starts with basic traffic lights that cycle between green, yellow and red. It is then expanded to include pedestrian lights, a push button for pedestrians to request a walk signal, a motion sensor to detect pedestrians, an LCD display to show messages, and a temperature sensor to display the temperature. Each step provides the additional components needed and code modifications to integrate the new functionality. The full project creates an intelligent traffic light system that assists both drivers and pedestrians safely.
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/ 17

Interactive Traffic Light project with Arduino

1 step - Car Traffic Light


We are going to create a set of traffic lights that will
change from green to red, via amber, and back
again, after a set length of time using the 4-state
system.

You will need:

Breadboard

Red Diffused LED

Yellow Diffused LED

Green Diffused LED

3 x 220 Ω Resistors

Jumper Wires

Connect it up:
2

We have connected 3 LEDʼs with the Anode of each one going to Digital Pins 10, 11 and 12, via
a 220Ω resistor each.
Interfacing of Components
1. Green LED interface to digital pin no. 10 via 220 ohm resistor
2. Yellow LED interface to digital pin no. 11 via 220 ohm resistor
3. Red LED interface to digital pin no. 12 via 220 ohm resistor

We have taken a jumper wire from Ground to the Ground rail at the top of the breadboard and a
ground wire goes from the Cathode leg of each LED to the common ground rail.
Enter the code:

This program have two functions, the first function is called setup() and itʼs purpose is to setup
anything necessary for our program to work before the main program loop runs.
The loop() function is the main program function and runs continuously as long as Arduino is
turned on. Every statement within the loop() function (within the curly braces) is carried out, one
by one, step by step, until the bottom of the function is reached, then the loop starts again at the
top of the function, and so on forever or until you turn the Arduino off or press the Reset switch.
3

2 step – Add Pedestrian Lights


Now we are going to extend the previous step to include
a set of pedestrian lights. The lights will change from
green to red and back again after the appropriate car
lights change using the 2-state system.

You will need:

2 x Breadboard

2 x Red Diffused LED

Yellow Diffused LED

2 x Green Diffused LED

5 x 150 Ω Resistors

Jumper Wires

We have connected 3 LEDʼs for car traffic lights with the Anode of each one going to Digital Pins
10, 11 and 12, via a 150Ω resistor each and 2 LEDʼs for pedestrian lights with the Anode of each
one going to Digital Pins 8 and 9 via a 150Ω resistor each.
Interfacing of Components
1. Car Green LED interface to digital pin no. 10 via 150 ohm resistor
2. Car Yellow LED interface to digital pin no. 11 via 150 ohm resistor
3. Car Red LED interface to digital pin no. 12 via 150 ohm resistor
4. Pedestrian Green LED interface to digital pin no. 9 via 150 ohm resistor
5. Pedestrian Red LED interface to digital pin no. 8 via 150 ohm resistor
4
Connect it up:

Enter the code (add red marked code to the previous):


5
3 step – Add Pedestrian Push Button
Now we are going to extend the previous step to include a pedestrian push button to request to
cross the road. The Arduino will react when the button is pressed by changing the state of the
lights to make the cars stop and allow the pedestrian to cross safely.
You will need:

2 x Breadboard

2 x Red Diffused LED

Yellow Diffused LED

2 x Green Diffused LED

6 x 150 Ω Resistors

Tactile Switch

Jumper Wires

Interfacing of Components
1. Car Green LED interface to digital pin no. 10 via 150 ohm resistor
2. Car Yellow LED interface to digital pin no. 11 via 150 ohm resistor
3. Car Red LED interface to digital pin no. 12 via 150 ohm resistor
4. Pedestrian Green LED interface to digital pin no. 9 via 150 ohm resistor
5. Pedestrian Red LED interface to digital pin no. 8 via 150 ohm resistor
6. Push Button interface to digital pin no. 2 via 150 ohm resistor
6

Connect it up:

Enter the code:


Add red marked code to the previous into setup() function:

Move the previous code from the loop() function to the new function changeLights() (see below)
and renew loop() function with the code:
7

4 step – Add Pedestrian Passive Infrared Motion Sensor


Now we will extend the previous step to include a passive infrared motion sensor to detect
pedestrians who want to cross the road. The Arduino will react when the motion is detected by
changing the state of the lights to make the cars stop and allow the pedestrian to cross safely.
You will need:

2 x Breadboard

2 x Red Diffused LED

Yellow Diffused LED

2 x Green Diffused LED

6 x 150 Ω Resistors
8

Tactile Switch

PIR Sensor

Jumper Wires

Interfacing of Components
1. Car Green LED interface to digital pin no. 10 via 150 ohm resistor
2. Car Yellow LED interface to digital pin no. 11 via 150 ohm resistor
3. Car Red LED interface to digital pin no. 12 via 150 ohm resistor
4. Pedestrian Green LED interface to digital pin no. 9 via 150 ohm resistor
5. Pedestrian Red LED interface to digital pin no. 8 via 150 ohm resistor
6. Push Button interface to digital pin no. 2 via 150 ohm resistor
7. PIR Sensor interface to digital pin no. 4
Connect it up:

Enter the code (Add red marked code to the previous):


9
10

5 step – Add LCD to display a message


In this step we will extend the previous solution with LCD to pay pedestrians’ attention by
displaying appropriate message.
You will need:

2 x Breadboard

2 x Red Diffused LED

Yellow Diffused LED

2 x Green Diffused LED

6 x 150 Ω Resistors

220 Ω Resistor

Tactile Switch

PIR Sensor

LCD

Potentiometer

Jumper Wires
11

Interfacing of Components
1. Car Green LED interface to digital pin no. 10 via 150 ohm resistor
2. Car Yellow LED interface to digital pin no. 11 via 150 ohm resistor
3. Car Red LED interface to digital pin no. 12 via 150 ohm resistor
4. Pedestrian Green LED interface to digital pin no. 9 via 150 ohm resistor
5. Pedestrian Red LED interface to digital pin no. 8 via 150 ohm resistor
6. Push Button interface to digital pin no. 2 via 150 ohm resistor
7. PIR Sensor interface to digital pin no. 4
8. LCD interfacing:
8.1. GND to ground pin
8.2. VCC to 5V
8.3. contrast(v0) to potentiometer
8.4. Register select(RS) to digital pin no.13
8.5. Read/write(RW) to ground pin
8.6. Enable to digital pin no. 7
8.7. DB4 to digital pin no. 6
8.8. DB5 to digital pin no. 5
8.9. DB6 to digital pin no. 3
8.10. DB7 to digital pin no. 1
Connect it up:

Enter the code (Add red marked code to the previous):


12
13

6 step – Add Temperature Sensor to show air temperature


In the last step we will extend the previous solution with Temperature Sensor to show air
temperature (in both degrees Celsius and Fahrenheit) on LCD screen until pedestrian pushes the
button or motion will be detected.
It will be obtained the ADC reading and calculated the analog voltage value from it. Then this
voltage value will be used to calculate the temperature in both degrees Celsius and Fahrenheit
according to the formulas:
voltage = sensorData * (5.0 / 1024.0);
celsius = (voltage - 0.5) * 100;
fahrenheit = (celsius * 9.0 / 5.0) + 32.0;
Temperature values will get updated to new ones after every second.
You will need:

2 x Breadboard

2 x Red Diffused LED

Yellow Diffused LED

2 x Green Diffused LED

6 x 150 Ω Resistors

220 Ω Resistor
14

Tactile Switch

PIR Sensor

LCD

Potentiometer

Temperature Sensor

Jumper Wires

Interfacing of Components
1. Car Green LED interface to digital pin no. 10 via 150 ohm resistor
2. Car Yellow LED interface to digital pin no. 11 via 150 ohm resistor
3. Car Red LED interface to digital pin no. 12 via 150 ohm resistor
4. Pedestrian Green LED interface to digital pin no. 9 via 150 ohm resistor
5. Pedestrian Red LED interface to digital pin no. 8 via 150 ohm resistor
6. Push Button interface to digital pin no. 2 via 150 ohm resistor
7. PIR Sensor interface to digital pin no. 4
8. LCD interfacing:
8.1. GND to ground pin
8.2. VCC to 5V
8.3. contrast(v0) to potentiometer
8.4. Register select(RS) to digital pin no.13
8.5. Read/write(RW) to ground pin
8.6. Enable to digital pin no. 7
8.7. DB4 to digital pin no. 6
8.8. DB5 to digital pin no. 5
8.9. DB6 to digital pin no. 3
8.10. DB7 to digital pin no. 1
9. Temperature Sensor interface to analog pin A0
15

Connect it up:

Enter the code (Add red marked code to the previous):


16
17

You might also like