Arduino Traffic Light Project: Step-by-Step Guide (2026)
Components Required
Before starting, gather the following components:
- Arduino Uno (or any compatible board) — 1
- Red LED — 1
- Yellow LED — 1
- Green LED — 1
- 220Ω Resistors — 3
- Breadboard — 1
- Jumper Wires — a few
- USB Cable (to connect the Arduino)

Step 1: Understand the Circuit Diagram
Before wiring anything, it helps to understand the logic. Each LED will be connected to a separate digital pin on the Arduino:
- Red LED → Pin 8
- Yellow LED → Pin 9
- Green LED → Pin 10
Each LED will be connected in series with a 220Ω resistor to limit current and protect the LED from burning out.

Step 2: Wiring on the Breadboard
Now let’s build the circuit physically:
- Connect the anode (longer leg) of each LED to one end of its corresponding resistor.
- Connect the other end of each resistor to the respective digital pin on the Arduino (8, 9, 10).
- Connect the cathode (shorter leg) of each LED to the breadboard’s ground (GND) rail.
- Connect the Arduino’s GND pin to the breadboard’s ground rail using a jumper wire.

Tip: Double-check LED polarity (anode/cathode) before connecting. Reversed LEDs simply won’t light up.
Step 3: Writing the Code in Arduino IDE
Now open the Arduino IDE and upload the following code. Each part is explained below:
cpp
int redLED = 8;
int yellowLED = 9;
int greenLED = 10;
void setup() {
pinMode(redLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
pinMode(greenLED, OUTPUT);
}
void loop() {
// Green Light ON
digitalWrite(greenLED, HIGH);
delay(5000);
digitalWrite(greenLED, LOW);
// Yellow Light ON
digitalWrite(yellowLED, HIGH);
delay(2000);
digitalWrite(yellowLED, LOW);
// Red Light ON
digitalWrite(redLED, HIGH);
delay(5000);
digitalWrite(redLED, LOW);
}How the Code Works
pinMode()sets each pin as an OUTPUT.- Inside
loop(), each LED turns ON and OFF in sequence, mimicking a real traffic signal’s timing pattern. delay()controls how long each light stays on (in milliseconds).
Step 4: Upload and Test
- Connect the Arduino board to your computer using a USB cable.
- In Arduino IDE, go to Tools and select the correct Board and Port.
- Click the Upload button.
- Once uploaded, the LEDs will start cycling on and off — just like a real traffic signal.
Common Issues and Fixes
| Issue | Possible Cause | Fix |
|---|---|---|
| LED not lighting up | Reversed polarity | Correct the anode/cathode orientation |
| All LEDs light up together | Wrong pin numbers in code | Match code pin numbers with circuit wiring |
| Upload error | Wrong Board/Port selected | Select the correct Board and Port from Tools menu |
Next Steps: Level Up This Project
Once the basic version works, you can extend it further with:
- A Push Button for a pedestrian crossing signal
- A PIR Sensor for automatic traffic detection
- A 4-way Traffic Signal System for controlling multiple directions
To dig deeper into Arduino functions and programming, check out the official Arduino reference documentation: Arduino Official Reference Documentation
Conclusion
The Traffic Light project is a great milestone in learning Arduino — it gives you practical experience with digitalWrite(), delay(), and basic sequential logic. If you’re completely new to Arduino and haven’t built anything before, start with our Arduino LED Blinking Project: Step-by-Step Guide to learn the basics, then come back to this project.
2 Comments