Overview
This project deals with a 2-road crossing traffic light. These lights work the same as our traffic system does here. Resistors are used so that no extra current is given to the LEDs, as the extra current can damage them.
In this traffic light signal, when signal 1 is red, signal 2 will be green and vice versa.
Hardware requiredÂ
- Arduino Uno R3
- LED
- Resistor
- Jumper Wires
Schematic Diagram

Fig 1. Circuit Diagram
Arduino Code :Â
// light one
int red1 = 10;
int yellow1 = 9;
int green1 = 8;
// light two
int red2 = 13;
int yellow2 = 12;
int green2 = 11;
void setup(){
// light one
pinMode(red1, OUTPUT);
pinMode(yellow1, OUTPUT);
pinMode(green1, OUTPUT);
// light two
pinMode(red2, OUTPUT);
pinMode(yellow2, OUTPUT);
pinMode(green2, OUTPUT);
}
void loop(){
changeLights();
delay(15000);
}
void changeLights(){
// turn both yellows on
digitalWrite(green1, LOW);
digitalWrite(yellow1, HIGH);
digitalWrite(yellow2, HIGH);
delay(5000);
// turn both yellows off, and opposite green and red
digitalWrite(yellow1, LOW);
digitalWrite(red1, HIGH);
digitalWrite(yellow2, LOW);
digitalWrite(red2, LOW);
digitalWrite(green2, HIGH);
delay(5000);
// both yellows on again
digitalWrite(yellow1, HIGH);
digitalWrite(yellow2, HIGH);
digitalWrite(green2, LOW);
delay(3000);
// turn both yellows off, and opposite green and red
digitalWrite(green1, HIGH);
digitalWrite(yellow1, LOW);
digitalWrite(red1, LOW);
digitalWrite(yellow2, LOW);
digitalWrite(red2, HIGH);
delay(5000);
}
Precautions
- Connections should be done properly.
- Arduino is case Sensitive, so code accordingly.
- Give different and appropriate colours to the wires.
Conclusion
This project demonstrates how a simple Arduino Uno can effectively control a 2-road traffic light system using LEDs, resistors, and basic coding. By simulating real-world traffic signals, beginners can strengthen their understanding of microcontrollers, electronics, and logic building.
Projects like these are a stepping stone toward more advanced embedded systems and IoT applications. To further enhance your learning journey and explore structured programs, check out coding schools.