Traffic Light Robotic Kit– Assembly Video & Arduino Code

Traffic Light Robotic Kit– Assembly Video & Arduino Code

Assembly Video

🛒 Buy This Robotic Kit Now

Code

// C++ Arduino Code (Copy Below)

// Traffic Signal: Red → Green → Blink Green 3× → Yellow → Red loop

const int RED_PIN    = 2;

const int YELLOW_PIN = 3;

const int GREEN_PIN  = 4;

// Updated timings (milliseconds)

unsigned long T_RED    = 7000;  // Red ON for 7 seconds

unsigned long T_GREEN  = 7000;  // Green ON for 7 seconds

unsigned long T_YELLOW = 3000;  // Yellow ON for 3 seconds

unsigned long T_BLINK  = 400;   // Green blink: ON/OFF every 0.4 sec

 

void setup() {

  pinMode(RED_PIN, OUTPUT);

  pinMode(YELLOW_PIN, OUTPUT);

  pinMode(GREEN_PIN, OUTPUT);

 

  // All lights off initially

  digitalWrite(RED_PIN, LOW);

  digitalWrite(YELLOW_PIN, LOW);

  digitalWrite(GREEN_PIN, LOW);

}

 

void loop() {

 

  // 🔴 RED Light

  digitalWrite(RED_PIN, HIGH);

  digitalWrite(YELLOW_PIN, LOW);

  digitalWrite(GREEN_PIN, LOW);

  delay(T_RED);

 

  // 🟢 GREEN Light

  digitalWrite(RED_PIN, LOW);

  digitalWrite(YELLOW_PIN, LOW);

  digitalWrite(GREEN_PIN, HIGH);

  delay(T_GREEN);

  // 🟢 Blink GREEN 3 times

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

    digitalWrite(GREEN_PIN, LOW);

    delay(T_BLINK);

    digitalWrite(GREEN_PIN, HIGH);

    delay(T_BLINK);

  }

  // 🟡 YELLOW Light

  digitalWrite(GREEN_PIN, LOW);

  digitalWrite(YELLOW_PIN, HIGH);

  delay(T_YELLOW);

 

  // After this, loop repeats automatically

}


 

What You Need for This Project

To build this Automatic Goalkeeper, we used the following parts from the Plzpapa Basic Robotic Kit:

  • Arduino Uno Board
  • Traffic Light
  • Wooden Goalkeeper Structure
  • Jumper Wires
  • (No soldering required!)
Back to blog