ArrowtronElectronics Store
Free shipping over ₹999
100% genuine components
Dispatch in 1–2 days
Secure payments · UPI, Cards

4-Way Traffic Light Controller — A Perfect First Arduino Project

Red, yellow, green — in the right order, with the right timing. The friendliest possible introduction to digital outputs and timing.

Beginner~30 minutes6 components

What you’ll build

Three LEDs cycle through the classic Indian junction sequence: green → yellow → red and back, with a blinking-yellow night mode when you hold the button. Once this makes sense, you understand half of embedded programming.

Components you’ll need

ComponentQtyPrice
Arduino Nano ATmega328P Compatible Board1₹149
5mm Red LED1₹149
5mm Yellow LED1₹199
5mm Green LED1₹19
220 Ohm 1/4W3₹147
400 Point Breadboard1₹299
Total₹962

Step-by-step guide

  1. Wire the red LED to D2, yellow to D3, green to D4 — each long leg through a 220Ω resistor, short legs to GND.
  2. Upload the sketch: green runs 5 seconds, yellow 2, red 5, forever.
  3. Study the loop and change the timings — make rush-hour and midnight versions.
  4. Stretch goal: add a second set of LEDs for the cross street and keep both directions safe (both red during changeover).

The code

The whole controller is one loop and three variables — tweak away.

const int red=2, yellow=3, green=4;
const int GREEN_MS=5000, YELLOW_MS=2000, RED_MS=5000;
void setup(){
  pinMode(red,OUTPUT); pinMode(yellow,OUTPUT); pinMode(green,OUTPUT);
}
void all(int r,int y,int g){ digitalWrite(red,r); digitalWrite(yellow,y); digitalWrite(green,g); }
void loop(){
  all(0,0,1); delay(GREEN_MS);   // go
  all(0,1,0); delay(YELLOW_MS);  // slow down
  all(1,0,0); delay(RED_MS);     // stop
}

The complete, ready-to-upload sketch and wiring diagram are on GitHub:

View full project on GitHub
GitHub link is a placeholder — replace it with your project repository URL.

Build this project

Add all 6 required components to your cart in one click — total ₹962.

Add all components to cart
Scroll to Top