Interactive Traffic Light Project 240120 210417
Interactive Traffic Light Project 240120 210417
Breadboard
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 x Breadboard
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:
2 x Breadboard
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:
Move the previous code from the loop() function to the new function changeLights() (see below)
and renew loop() function with the code:
7
2 x Breadboard
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:
2 x Breadboard
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:
2 x Breadboard
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: