Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Based Traffic Light Simulator

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Traffic Light Simulator

Traffic Light Simulation Circuit Documentation

Summary

This circuit is designed to simulate a traffic light using an Arduino UNO microcontroller and three LEDs (red, yellow, and green). The Arduino UNO controls the state of each LED to mimic the behavior of a traffic light: the red LED lights up for 6 seconds, the yellow LED for 2 seconds, and the green LED for 20 seconds. This sequence repeats indefinitely.

Component List

Arduino UNO

LED: Two Pin (red)

LED: Two Pin (green)

LED: Two Pin (yellow)

Wiring Details

Arduino UNO

LED: Two Pin (red)

LED: Two Pin (green)

LED: Two Pin (yellow)

Documented Code

/*
 * This Arduino sketch controls three LEDs (red, yellow, green) connected to
 * an Arduino UNO to simulate a traffic light. The red LED is on for 6 seconds,
 * the yellow LED is on for 2 seconds, and the green LED is on for 20 seconds.
 */

// Pin definitions
const int redLEDPin = 13;
const int yellowLEDPin = 12;
const int greenLEDPin = 11;

void setup() {
  // Initialize the LED pins as outputs
  pinMode(redLEDPin, OUTPUT);
  pinMode(yellowLEDPin, OUTPUT);
  pinMode(greenLEDPin, OUTPUT);
}

void loop() {
  // Turn on the red LED
  digitalWrite(redLEDPin, HIGH);
  delay(6000); // Wait for 6 seconds
  digitalWrite(redLEDPin, LOW);

  // Turn on the yellow LED
  digitalWrite(yellowLEDPin, HIGH);
  delay(2000); // Wait for 2 seconds
  digitalWrite(yellowLEDPin, LOW);

  // Turn on the green LED
  digitalWrite(greenLEDPin, HIGH);
  delay(20000); // Wait for 20 seconds
  digitalWrite(greenLEDPin, LOW);
}

The code is written for the Arduino UNO and is responsible for controlling the timing and state of each LED to simulate a traffic light pattern. The setup() function initializes the LED pins as outputs, and the loop() function contains the logic to turn each LED on and off in the correct sequence.