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.

This is 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 Parts List

R1,R2,R3
220 Ω
U1
Arduino UNO
D1
Green LED
D3
Red LED
D2
Yellow LED

How to Build the Arduino Traffic Lights

Code for the Arduino:

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.