Notification texts go here Contact Us Buy Now!

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)
  • APPS AND ONLINE SERVICES (Ide web, Arduino IDE

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

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.
NextGen Digital Welcome to WhatsApp chat
Howdy! How can we help you today?
Type here...