How to Build a Traffic Light Simulation Using Arduino

How to Build a Traffic Light Simulation Using Arduino
1
0
2 min read

Meta Description:
Simulate a real-world traffic light system using Arduino UNO in this hands-on tutorial. Includes circuit diagram, code, components list, working demo, and expansion ideas.


Introduction

In this beginner-friendly hands-on project, we will simulate a Traffic Light Control System using an Arduino UNO. The project is designed to mimic the role of real traffic lights at a road intersection. It uses three LEDs – Red, Yellow, and Green.

What the Project Does

It simulates a traffic signal system by turning ON/OFF three LEDs in a timed sequence (Red β†’ Green β†’ Yellow β†’ Red…).

Real-World Use Case

Traffic light control is a foundational concept in automation and embedded systems. It is often used in smart city infrastructure and pedestrian safety systems.

Skill Level

Beginner to Intermediate

Expected Outcome

You’ll understand basic sequential programming, digital outputs, and timing control in Arduino. You’ll also gain confidence working with multiple outputs.


Components Required

QuantityPartDescriptionBuy Link
1Arduino UNO BoardMain micro controller boardBuy on Elecsynergy
1BreadboardFor easy prototypingBuy on Elecsynergy
3LEDs (Red, Yellow, Green)To represent traffic lightsBuy on Elecsynergy
3220 ohm ResistorsTo protect LEDs from overcurrentBuy on Elecsynergy
6Male to Male Jumper WiresFor connectionsBuy on Elecsynergy

Circuit Diagram + Explanation

Connection Summary:

  • Red LED β†’ Pin 10
  • Yellow LED β†’ Pin 9
  • Green LED β†’ Pin 8
  • Each LED connects to its respective Arduino digital pin through a 220 ohm resistor
  • Cathode of each LED goes to GND

Visual Diagram:

πŸ”§ Tip: Always use resistors in series with LEDs to prevent burning them.


Arduino Code

// Traffic Light Simulation Using Arduino

int redLED = 10;
int yellowLED = 9;
int greenLED = 8;

void setup() {
  pinMode(redLED, OUTPUT);
  pinMode(yellowLED, OUTPUT);
  pinMode(greenLED, OUTPUT);
}

void loop() {
  // Red Light
  digitalWrite(redLED, HIGH);
  digitalWrite(yellowLED, LOW);
  digitalWrite(greenLED, LOW);
  delay(5000); // 5 seconds

  // Green Light
  digitalWrite(redLED, LOW);
  digitalWrite(greenLED, HIGH);
  delay(5000); // 5 seconds

  // Yellow Light
  digitalWrite(greenLED, LOW);
  digitalWrite(yellowLED, HIGH);
  delay(2000); // 2 seconds
}

Working Explanation

  • pinMode() sets digital pins as output
  • LEDs turn ON/OFF based on digitalWrite() method
  • delay() is used to control how long each light remains on
  • The sequence mimics standard traffic signals in real life

Demo / Output Preview

πŸ’‘ You will see:

  • Red LED ON for 5s
  • Green LED ON for 5s
  • Yellow LED ON for 2s
  • Loop continues indefinitely

Troubleshooting & Tips

  • Check LED orientation (long leg = anode)
  • Make sure correct resistor values (220Ξ© to 330Ξ©)
  • Confirm your Arduino port is selected in the IDE

Project Expansion Ideas

  • Add a pedestrian cross button with separate green signal
  • Control LEDs using Bluetooth via mobile app
  • Add sound output using buzzer during pedestrian signal
  • Use Real-Time Clock module for time-based traffic control

Conclusion

You’ve now built your own Traffic Light Simulator using Arduino! This project teaches core programming concepts like sequencing and digital output control. It’s a great stepping stone toward more advanced automation projects.

Stay tuned for the next project in our Arduino Series and tag us when you recreate this project!


πŸ›’ Buy the Complete Kit

Available on Elecsynergy


#ArduinoProjects #TrafficLightWithArduino #InnovateYourself #Elecsynergy

Leave a Reply