Arduino Traffic Light Project >>>> Super Easy Tutorial for Beginners

 Yo guys!  Today we’re gonna make a simple traffic light system using an Arduino UNO + breadboard + some LEDs. Don’t stress, it’s beginner-friendly and lowkey fun to do. Let’s gooo!

Stuff You’ll Need

  • 1x Arduino UNO (our lil’ brain 🧠)

  • 1x Breadboard (the playground for components)

  • 3 LEDs (Red ❤️, Yellow 💛, Green 💚) – actually 6 if you copy my code

  • 6 Resistors (220Ω or 330Ω, so the LEDs don’t go boom 💥)

  • Jumper Wires (a bunch, trust me)

  • USB Cable (to connect Arduino to your PC/laptop)

 Circuit Setup

Check out the setup in the pic 👇

  • Connect the LEDs to pins 2, 3, 4 (for the first set) and pins 5, 6, 7 (for the second set).

  • Each LED must go through a resistor to GND.

  • Long leg (anode/+) → Arduino pin.

  • Short leg (cathode/-) → resistor → GND.

Basically:
🔴 Red LED → pin 2 & 5
🟡 Yellow LED → pin 3 & 6
🟢 Green LED → pin 4 & 7

this ur code :

int LedMerah = 2;

int LedKuning = 3;

int LedHijau = 4;

int LedMerah1 = 5;

int LedKuning1 = 6;

int LedHijau1 = 7;


void setup() {

  pinMode (LedMerah, OUTPUT);

  pinMode (LedKuning, OUTPUT);

  pinMode (LedHijau, OUTPUT);

  pinMode (LedMerah1, OUTPUT);

  pinMode (LedKuning1, OUTPUT);

  pinMode (LedHijau1, OUTPUT);

}


void loop() {

  // First traffic light

  digitalWrite (LedMerah, HIGH);

  digitalWrite (LedKuning, LOW);

  digitalWrite (LedHijau, LOW);

  delay (5000);


  // Yellow blinking

  for(int i=0; i<5; i++){

    digitalWrite(LedKuning, HIGH);

    delay(100);

    digitalWrite(LedKuning, LOW);

    delay(100);

  }


  // Green ON

  digitalWrite (LedHijau, HIGH);

  delay (5000);


  // Second traffic light

  digitalWrite (LedMerah1, HIGH);

  delay (5000);


  for(int i=0; i<5; i++){

    digitalWrite(LedKuning1, HIGH);

    delay(100);

    digitalWrite(LedKuning1, LOW);

    delay(100);

  }


  digitalWrite (LedHijau1, HIGH);

  delay (5000);

}

What’s Happening

  • Red LED = STOP 🛑

  • Yellow LED = WAIT ⚠️ (it even blinks, cool right?)

  • Green LED = GO ✅

It works like a real traffic light, just mini size 😎

And that’s it, fam! You just made your own mini traffic light system with Arduino. Play around with the delays if you want the lights to last longer or blink faster.

Now flex this project to your teacher or friends and say:

“Yup, I basically control traffic now.” 😏

Komentar

Postingan populer dari blog ini

How to Make Arduino LCD Show Lyrics in wokwi

Arduino Buzzer Music Tutorial (Play Do-Re-Mi with Arduino)

Arduino + Ultrasonic Sensor HC-SR04 Tutorial