Arduino Traffic Light Simulator - Bulu Pradhan

Friday, August 20, 2021

Arduino Traffic Light Simulator

Project Description:

Simulate a traffic light using Arduino and LEDs! This project is so cool to watch and easy to do!

This simple little project uses Arduino and other LEDs to replicate the traffic light. It uses the code as an internal timer and continues to work until you cut out the Arduino power supply.

Using Materials

  • Arduino UNO
  • Breadboard (generic)
  • Jumper wires (generic) Male/Male required
  • LED (generic) You will need red, green, and blue lights
  • Arduino USB 2.0 data Cable (Mfr 25frf52 100r sml)
  • Resistor 100 ohm (Brown, Black, Brown)

Schematic Diagram

Program Code

// variables int GREEN = 2; int YELLOW = 3; int RED = 4; int DELAY_GREEN = 5000; int DELAY_YELLOW = 2000; int DELAY_RED = 5000; // basic functions void setup() { pinMode(GREEN, OUTPUT); pinMode(YELLOW, OUTPUT); pinMode(RED, OUTPUT); } void loop() { green_light(); delay(DELAY_GREEN); yellow_light(); delay(DELAY_YELLOW); red_light(); delay(DELAY_RED); } void green_light() { digitalWrite(GREEN, HIGH); digitalWrite(YELLOW, LOW); digitalWrite(RED, LOW); } void yellow_light() { digitalWrite(GREEN, LOW); digitalWrite(YELLOW, HIGH); digitalWrite(RED, LOW); } void red_light() { digitalWrite(GREEN, LOW); digitalWrite(YELLOW, LOW); digitalWrite(RED, HIGH); }

Post a Comment