Arduino Traffic Lights

This circuit is live in Circuit Canvas. Open it to explore every part and wire, or make your own copy to change values, swap parts and build your own version. Free, right in your browser.

A simple traffic light project that simulates the behaviour of European traffic lights: first red, then red + yellow, then green, then yellow. This repeats over and over. You can tweak the times for each stage in the code.

Arduino Traffic Lights Schematic

Each LED has its own 220 Ω resistor to limit the current. The Arduino pins give 5 V, and a red or yellow LED drops about 2 V, so the resistor gets the remaining 3 V. That gives about 3 V / 220 Ω ≈ 14 mA, which makes the LEDs nice and bright while staying well below the 20 mA an Arduino pin should supply. A green LED drops a bit more, so it gets slightly less current. Want dimmer lights? Use a bigger resistor, like 470 Ω or 1 kΩ.

Arduino Traffic Lights Parts List

D1
Green
D2
Yellow
D3
Red
R1-R3
220Ω
U1
Arduino UNO R3

Code

sketch.ino
const int redPin = 6;
const int yellowPin = 3;
const int greenPin = 0;

void setup() {
  pinMode(redPin, OUTPUT);
  pinMode(yellowPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
}

void loop() {
  // Red light ON
  digitalWrite(greenPin, LOW);
  digitalWrite(yellowPin, LOW);
  digitalWrite(redPin, HIGH);
  delay(5000); // Red for 5 seconds

  // Red and Yellow ON together
  digitalWrite(greenPin, LOW);
  digitalWrite(yellowPin, HIGH);
  digitalWrite(redPin, HIGH);
  delay(2000); // Red + Yellow for 2 seconds

  // Green ON
  digitalWrite(greenPin, HIGH);
  digitalWrite(yellowPin, LOW);
  digitalWrite(redPin, LOW);
  delay(5000); // Green for 5 seconds

  // Yellow ON
  digitalWrite(greenPin, LOW);
  digitalWrite(yellowPin, HIGH);
  digitalWrite(redPin, LOW);
  delay(2000); // Yellow for 2 seconds
}

Make it your own

Every circuit here is a live project in Circuit Canvas, not just a picture. Copy this one and change a value, swap a part or move it to a stripboard: the schematic and the breadboard layout are linked, so a part added to one appears in the other.

Or start from a blank canvas and draw your own circuit, with thousands of ready-made parts.