The Best DIY STEM Tutorials and Projects

Traffic light signals

OVERVIEW

In this project, we’ll build a mini traffic light using Arduino and LEDs! Just like real traffic lights, our setup will cycle through red, yellow, and green signals to control the “traffic.” This is a fun way to learn about timing, sequencing, and how Arduino controls multiple outputs. Let’s bring the streets to life with code! 🚗💡

You can follow this video and the instructions below.

Video

Components Required

Here is a list of Components that we will need to make this Project.

Electronic-Dice_Componnets.
Sr #Item NameQuantity
1Arduino Uno1
2Breadboard1
3Resistors1
4M-F Jumper wires7
5LEDs3
6Arduino cable1

Wiring Diagram

Here is a Complete Wiring Diagram along with Instructions for this Project

Electronic-Dice_Circuit-diagram

Program / Code

Code is Explained in the Comments of the Code

const int redPin = 8;
const int yellowPin = 10;
const int greenPin = 12;

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

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

  
  // Yellow light for 2 seconds (transition from red to green)
  digitalWrite(redPin, LOW);
  digitalWrite(yellowPin, HIGH);
  digitalWrite(greenPin, LOW);
  delay(2000);

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

}

Thank you so much for going through our tutorial, we hope it was easy to follow and you enjoyed it, please share your feedback and pictures of the project (if you have made it) in the comments below .!

Share your love

Leave a Reply

Your email address will not be published. Required fields are marked *