Arduino UNO Traffic Light Control System – Smart LED Signal Project
Simulate a real-world road traffic signal using an Arduino UNO and three LEDs. Learn digital output control, the delay() timing function, and sequential automation logic — the perfect first embedded systems project.
🔴 Red LED — STOP
Pin 1 · HIGH for 5 seconds
🟡 Yellow LED — SLOW DOWN
Pin 2 · HIGH for 2 seconds
🟢 Green LED — GO
Pin 3 · HIGH for 5 seconds
Components Required
Arduino UNO
ATmega328P · 14 digital I/O pins
Red LED
5mm standard · 2.0V forward voltage
Yellow LED
5mm standard · 2.1V forward voltage
Green LED
5mm standard · 2.1V forward voltage
3× 220Ω Resistors
Current limiting for each LED
Jumper Wires
Male-to-male · assorted colors
Breadboard
Half-size or full — 400/830 tie points
Arduino IDE
v2.x recommended · USB-A to USB-B cable
Circuit Diagram
arduino_traffic_light_circuit.svg
Annotated
Pin Connections
| Arduino Pin | LED | Via Resistor | Action | Duration |
|---|---|---|---|---|
| D1 | 🔴 Red LED | 220Ω → Anode | STOP | 5 seconds |
| D2 | 🟡 Yellow LED | 220Ω → Anode | SLOW DOWN | 2 seconds |
| D3 | 🟢 Green LED | 220Ω → Anode | GO | 5 seconds |
| GND | All LEDs (Cathode) | Common GND rail | Return path | Always |
Signal Timing Chart
One complete 12-second cycle — each bar represents 1 second
GREEN
YELLOW
RED
← Cycle repeats continuously via void loop()
diagram.json (Wokwi / Cirkit Designer)
💡 Simulate without hardware: Copy the JSON below and paste it into Wokwi.com or Cirkit Designer to run the traffic light simulation in your browser.
diagram.json
{
"version": 1,
"author": "MakeMindz",
"editor": "wokwi",
"parts": [
{
"type": "wokwi-arduino-uno",
"id": "uno",
"top": 0, "left": 0,
"attrs": {}
},
{
"type": "wokwi-resistor",
"id": "r-red",
"top": 80, "left": 260,
"attrs": { "value": "220" }
},
{
"type": "wokwi-resistor",
"id": "r-yellow",
"top": 140, "left": 260,
"attrs": { "value": "220" }
},
{
"type": "wokwi-resistor",
"id": "r-green",
"top": 200, "left": 260,
"attrs": { "value": "220" }
},
{
"type": "wokwi-led",
"id": "led-red",
"top": 60, "left": 380,
"attrs": { "color": "red" }
},
{
"type": "wokwi-led",
"id": "led-yellow",
"top": 120, "left": 380,
"attrs": { "color": "yellow" }
},
{
"type": "wokwi-led",
"id": "led-green",
"top": 180, "left": 380,
"attrs": { "color": "green" }
}
],
"connections": [
[ "uno:1", "r-red:1", "red", [] ],
[ "r-red:2", "led-red:A", "red", [] ],
[ "led-red:C", "uno:GND.1", "black", [] ],
[ "uno:2", "r-yellow:1", "yellow",[] ],
[ "r-yellow:2", "led-yellow:A", "yellow",[] ],
[ "led-yellow:C", "uno:GND.1", "black", [] ],
[ "uno:3", "r-green:1", "green", [] ],
[ "r-green:2", "led-green:A", "green", [] ],
[ "led-green:C", "uno:GND.1", "black", [] ]
]
}
Step-by-Step Instructions
-
1Gather All ComponentsCollect your Arduino UNO, 3 LEDs (red, yellow, green), 3 × 220Ω resistors, jumper wires, and a breadboard. Connect the Arduino to your computer via USB-B cable to verify the COM port is recognized in Device Manager / System Information.
-
2Place LEDs on the BreadboardInsert the three LEDs vertically into the breadboard in order: Red at top, Yellow in middle, Green at bottom. Ensure the longer leg (anode, +) and shorter leg (cathode, −) are in separate rows. Leave 2–3 rows of gap between each LED.⚠️ LED polarity matters — longer leg = anode (+), shorter leg = cathode (−)
-
3Add 220Ω Current-Limiting ResistorsPlace one 220Ω resistor in series with each LED's anode leg. The resistor connects between the Arduino digital pin wire and the LED anode. This limits current to ~15mA, protecting both the LED and Arduino pin (which can only source 40mA max).✅ Without resistors, LEDs may burn out within seconds — always use them
-
4Wire Arduino Pins to ResistorsConnect jumper wires from Arduino digital pins to each resistor:
• D1 → Red LED resistor
• D2 → Yellow LED resistor
• D3 → Green LED resistor
Use color-coded wires to match each LED for easy debugging. -
5Connect All LED Cathodes to GNDRun the cathode (short leg) of each LED to the negative rail of the breadboard. Then connect the negative breadboard rail to any Arduino GND pin with a black jumper wire. All three LEDs now share a common ground return path.
-
6Open Arduino IDE and Enter the CodeOpen Arduino IDE 2.x. Create a new sketch, delete the template code, and type (or paste) the traffic light sketch shown below. Verify the📦 Go to Tools → Board → Arduino UNO · Tools → Port → select your COM port
greenPin = 3,yellowPin = 2, andredPin = 1match your physical wiring. -
7Upload Sketch to ArduinoClick the ✓ (Verify) button to compile. If no errors appear, click → (Upload) to flash the sketch onto the Arduino UNO. The LEDs should immediately begin cycling: Green → Yellow → Red → repeat.⚠️ If upload fails: check COM port, try pressing Reset on Arduino just before upload starts
-
8Observe and Verify the TimingUse a stopwatch to verify the sequence: Green holds for 5 seconds, Yellow for 2 seconds, Red for 5 seconds, then repeats. Adjust the✅ Unplug the USB and power via DC barrel jack to run standalone
delay()values in the sketch to customize timing for your project — schools often prefer 3s/1s/3s for faster demos.
Arduino Sketch
Arduino C++
/* * Arduino UNO Traffic Light Control System * MakeMindz.com — Beginner Embedded Systems Tutorial * * Simulates a real traffic signal using 3 LEDs: * Green LED → Pin 3 → GO (5 seconds) * Yellow LED → Pin 2 → SLOW (2 seconds) * Red LED → Pin 1 → STOP (5 seconds) * * Each LED is connected via a 220Ω current-limiting resistor. * Total cycle time: 12 seconds (repeating) */ const int greenPin = 3; // Green LED → Digital Pin 3 const int yellowPin = 2; // Yellow LED → Digital Pin 2 const int redPin = 1; // Red LED → Digital Pin 1 void setup() { // Configure all LED pins as digital outputs pinMode(greenPin, OUTPUT); pinMode(yellowPin, OUTPUT); pinMode(redPin, OUTPUT); } void loop() { // ── Phase 1: GREEN — Vehicles GO ────────────────── digitalWrite(greenPin, HIGH); // Turn green ON delay(5000); // Hold for 5 seconds digitalWrite(greenPin, LOW); // Turn green OFF // ── Phase 2: YELLOW — Vehicles SLOW DOWN ────────── digitalWrite(yellowPin, HIGH); // Turn yellow ON delay(2000); // Hold for 2 seconds digitalWrite(yellowPin, LOW); // Turn yellow OFF // ── Phase 3: RED — Vehicles STOP ────────────────── digitalWrite(redPin, HIGH); // Turn red ON delay(5000); // Hold for 5 seconds digitalWrite(redPin, LOW); // Turn red OFF // Cycle restarts automatically — loop() repeats forever }
Try the Simulation
Wokwi Simulator — Arduino UNO Traffic Light
Paste the diagram.json above + the sketch code into Wokwi to simulate the full traffic signal in your browser — no hardware needed.
Cirkit Designer — Full Interactive Circuit
Build the complete traffic light circuit with drag-and-drop components, then run a live simulation with real-time LED toggle visualization.
Key Features
Beginner Friendly
Only 3 components beyond the Arduino — ideal as a first project
Timing Control
Learn
delay() for precise millisecond-accurate LED sequencingDigital I/O
Demonstrates
pinMode() and digitalWrite() fundamentalsContinuous Loop
Infinite cycling via
void loop() — just like real road signalsExhibition Ready
Ideal for school science fairs and STEM showcase events
Expandable
Solid foundation for smart city traffic management upgrades
Project Upgrades
🔘 Pedestrian Button
Add a push button interrupt — pressing it triggers an extended red phase for crossing
📡 Vehicle Detection
Use HC-SR04 ultrasonic sensor to detect waiting vehicles and adapt green duration
📺 Countdown Display
Add a 7-segment or LCD display showing remaining seconds for each phase
🌐 IoT Monitoring
Add ESP8266 Wi-Fi module to log traffic phases to a web dashboard via MQTT
🚦 Multi-Junction
Scale to 4-way intersection with 12 LEDs and synchronized phase logic
📱 GSM Alerts
Use SIM800L to send SMS alerts if a signal fault is detected (LED off unexpectedly)
.png)
Comments
Post a Comment