PrinceMatthew
Published © CC BY-NC-ND

The Traffic Light

Three LEDs: green, yellow and red that create a traffic light.

BeginnerFull instructions provided30 minutes7,010
The Traffic Light

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×7
LED (generic)
LED (generic)
1 green , 1 yellow 1 red
×3
Resistor 221 ohm
Resistor 221 ohm
×3

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

traffic light

If you don't understand the wiring, tell me in the comments section and I will help you.

Code

The traffic light

C/C++
#define LED_GREEN A0
#define LED_YELLOW A1
#define LED_RED A2
void setup() {
  // put your setup code here, to run once:
  Serial.begin (9600);
  pinMode(A0, OUTPUT);
  pinMode(A1, OUTPUT);
  pinMode(A2, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Go!");
  digitalWrite(A0, HIGH);
  delay (10000);
  digitalWrite(A0, LOW);
  Serial.println ("Stop!");
  digitalWrite(A2, HIGH);
  delay (10000);
  digitalWrite(A2, LOW);
  Serial.println("Reduce speed!");
  digitalWrite(A1, HIGH);
  delay (3000);
  digitalWrite(A1, LOW);
}

Credits

PrinceMatthew

PrinceMatthew

6 projects • 58 followers
Having fun while coding 🔥

Comments