Traffic Light Control System using Arduino
AIM
To design and implement a traffic light control system using Arduino that simulates the
operation of a typical traffic light.
REQUIRED ITEMS
- Arduino Uno board
- Red LED
- Yellow LED
- Green LED
- 3 × 220Ohm resistors
- Breadboard
- Jumper wires
- USB cable
- Computer with Arduino IDE
ARDUINO ALGORITHM
1. Start the system.
2. Set red, yellow, and green LED pins as output.
3. Turn on the green LED (vehicles can go) for 5 seconds.
4. Turn off the green LED.
5. Turn on the yellow LED (warning) for 2 seconds.
6. Turn off the yellow LED.
7. Turn on the red LED (vehicles must stop) for 5 seconds.
8. Turn off the red LED.
Traffic Light Control System using Arduino
9. Repeat the sequence indefinitely.
BLOCK DIAGRAM
Refer to the schematic showing the relationship between the Arduino and the three LEDs
(Red, Yellow, Green) each connected through resistors to digital output pins.
FLOWCHART
Start -> Set all LED pins as OUTPUT -> Turn ON Green LED -> Wait 5 sec -> Turn OFF Green,
Turn ON Yellow -> Wait 2 sec -> Turn OFF Yellow, Turn ON Red -> Wait 5 sec -> Turn OFF Red -
> Repeat
PROCEDURE
1. Connect the Red, Yellow, and Green LEDs to Arduino digital pins through 220Ohm resistors.
2. Connect the GND legs of all LEDs to Arduino GND.
3. Open Arduino IDE and connect the Arduino board via USB.
4. Write or paste the traffic light control code into the IDE.
5. Select the correct board and COM port.
6. Upload the code to the Arduino.
7. Observe the LEDs operating in the correct sequence.
CODE
const int redPin = 13;
const int yellowPin = 12;
const int greenPin = 11;
void setup()
{ pinMode(redPin, OUTPUT);
pinMode(yellowPin, OUTPUT);
pinMode(greenPin, OUTPUT);
Traffic Light Control System using Arduino
void loop()
{ digitalWrite(greenPin, HIGH);
delay(5000);
digitalWrite(greenPin, LOW);
digitalWrite(yellowPin, HIGH);
delay(2000);
digitalWrite(yellowPin, LOW);
digitalWrite(redPin, HIGH);
delay(5000);
digitalWrite(redPin, LOW);
}
RESULT
The traffic light control system operates successfully. The green LED turns on for 5 seconds,
followed by the yellow LED for 2 seconds, and the red LED for 5 seconds. This sequence repeats
continuously, simulating the behavior of a real traffic signal system.