Skip to content
Buy 10+ on select items — save 10% auto-applied
Free US shipping on orders $35+
Order by 3pm ET — ships same-day from the US
Worldwide shipping via DHL
Skip to main content

Arduino Uno LED Traffic Light: Build a Sequencing Controller

August 30, 2026 23 views

Arduino Uno LED Traffic Light: Build a Sequencing Controller | ShillehTek
Project

Build an Arduino Uno LED traffic light controller with clean go/caution/stop functions, realistic timings, and an easy upgrade path using ShillehTek parts.

30 min Beginner5 parts

Project Overview

Arduino Uno LED Traffic Light Controller: Build a three-LED traffic light (red, yellow, green) that cycles on realistic timings using clean, reusable functions instead of one giant loop.

  • Time: ~30 minutes
  • Skill level: Beginner
  • What you will build: A breadboard traffic light with clean stop()/caution()/go() functions that can be extended to a pedestrian button or a full 4-way intersection.
Arduino Uno traffic light build with red yellow and green LEDs on a breadboard
Red, yellow, green: the classic first sequencing project.

Parts List

From ShillehTek

External

  • None - everything is in the kits

Note: LEDs always need a current-limiting resistor (220a9 here). Long leg (anode) goes toward the Arduino pin; short leg goes to ground through the resistor.

Step-by-Step Guide

Step 1 - Wire the Three LEDs

Goal: Build the red, yellow, and green outputs on a breadboard.

What to do: Connect the red LED to D2, yellow to D4, and green to D6. For each LED, add a 220a9 resistor to the ground rail. Arrange the LEDs vertically so the layout matches a real traffic light.

Arduino Uno wiring diagram showing red yellow and green LEDs on D2 D4 and D6 with resistors to ground
Three LEDs on D2/D4/D6, each with its own resistor to ground.

Expected result: The three LEDs are wired and ready for code.

Step 2 - Write Functions for Each Light State

Goal: Create readable, reusable code that matches the traffic sequence.

What to do: Define pins for the LEDs, write a helper that sets all three, then create go(), caution(), and stop() functions that take a duration. Call them in loop() using realistic timing.

Code:

const int RED = 2, YELLOW = 4, GREEN = 6;

void setLights(bool r, bool y, bool g) {
  digitalWrite(RED, r);
  digitalWrite(YELLOW, y);
  digitalWrite(GREEN, g);
}

void go(int ms)      { setLights(LOW,  LOW,  HIGH); delay(ms); }
void caution(int ms) { setLights(LOW,  HIGH, LOW);  delay(ms); }
void stop(int ms)    { setLights(HIGH, LOW,  LOW);  delay(ms); }

void setup() {
  pinMode(RED, OUTPUT);
  pinMode(YELLOW, OUTPUT);
  pinMode(GREEN, OUTPUT);
}

void loop() {
  go(5000);        // green: 5 s
  caution(2000);   // yellow: 2 s
  stop(5000);      // red: 5 s
}

Expected result: The LEDs cycle green, then yellow, then red on the programmed timings.

Step 3 - Add a Pedestrian Button

Goal: Make the traffic light interactive.

What to do: Wire a tactile button from D8 to ground and set pinMode(8, INPUT_PULLUP). Check the button during the green phase. When pressed, jump to caution then stop early, and hold red a few extra seconds to simulate a crossing button.

Expected result: Pressing the button triggers an early change from green to yellow to red.

Step 4 - Scale to an Intersection

Goal: Extend the same pattern to two directions of traffic.

What to do: Add a second set of LEDs for the other road (D3/D5/D7). Interlock the logic so road B stays red while road A cycles, then swap. Keep using the same setLights idea, just expanded for the extra signal head.

Expected result: Two signal heads that never show green at the same time.

Conclusion

You built an Arduino Uno LED traffic light controller that cycles red, yellow, and green using simple state functions. This same structure can grow into button-controlled crossings, multiple signal heads, and eventually non-blocking timing when you outgrow delay().

Want the exact parts used in this build? Grab them from ShillehTek.com. If you want help customizing this project or building something for your product, check out our IoT consulting services.

Image credit: leos on Hackster.io.

Parts for this build

Everything used in this tutorial. Uncheck what you already have.

All 5 in stock
0 parts selected $0.00