Red, yellow and green LEDs that cycle just like a real road signal.
Built and tested by Anju.A · Industrial Robotics Institute

Traffic lights control vehicles and pedestrians at road junctions. This beginner project builds a working model with an Arduino and three LEDs. The program switches green, yellow and red on in the same order and timing as a real signal, then repeats.
| Component | Qty |
|---|---|
| Arduino Uno | 1 |
| Red LED | 1 |
| Yellow LED | 1 |
| Green LED | 1 |
| Breadboard | 1 |
| Jumper Wires | As needed |
| USB Cable | 1 |
| From | Connect to |
|---|---|
| Green LED + | Pin 2 |
| Green LED − | Pin 3 |
| Yellow LED + | Pin 4 |
| Yellow LED − | Pin 5 |
| Red LED + | Pin 6 |
| Red LED − | Pin 7 |
Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the Arduino Uno.
int greenPos = 2;
int greenNeg = 3;
int yellowPos = 4;
int yellowNeg = 5;
int redPos = 6;
int redNeg = 7;
void setup()
{
pinMode(greenPos, OUTPUT);
pinMode(greenNeg, OUTPUT);
pinMode(yellowPos, OUTPUT);
pinMode(yellowNeg, OUTPUT);
pinMode(redPos, OUTPUT);
pinMode(redNeg, OUTPUT);
}
void loop()
{
// GREEN LIGHT
digitalWrite(greenPos, HIGH); digitalWrite(greenNeg, LOW);
digitalWrite(yellowPos, LOW); digitalWrite(yellowNeg, LOW);
digitalWrite(redPos, LOW); digitalWrite(redNeg, LOW);
delay(5000);
// YELLOW LIGHT
digitalWrite(greenPos, LOW); digitalWrite(greenNeg, LOW);
digitalWrite(yellowPos, HIGH); digitalWrite(yellowNeg, LOW);
digitalWrite(redPos, LOW); digitalWrite(redNeg, LOW);
delay(2000);
// RED LIGHT
digitalWrite(greenPos, LOW); digitalWrite(greenNeg, LOW);
digitalWrite(yellowPos, LOW); digitalWrite(yellowNeg, LOW);
digitalWrite(redPos, HIGH); digitalWrite(redNeg, LOW);
delay(5000);
}Traffic lights control vehicles and pedestrians at road junctions. This beginner project builds a working model with an Arduino and three LEDs.
You need: Arduino Uno (1), Red LED (1), Yellow LED (1), Green LED (1), Breadboard (1), Jumper Wires, USB Cable (1). Software: Arduino IDE.
Yes. It is rated beginner and takes about 30–60 minutes to build, using the Arduino Uno. The guide on this page explains every connection and step.
The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.
Yes. IRI sells a kit with the parts for this project (PRJ-010). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.