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

Arduino UNO Controlled Traffic Light System

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled Traffic Light System

Traffic Light Controller Circuit Documentation

Summary

This circuit is designed to control a traffic light system using an Arduino UNO microcontroller and a traffic light module with three LEDs (Green, Yellow, and Red). The Arduino UNO cycles through the LEDs, illuminating the green light for 5 seconds, the yellow light for 2 seconds, and the red light for 5 seconds. This sequence repeats indefinitely to simulate a traffic light operation.

Component List

Arduino UNO

Traffic Light

Wiring Details

Arduino UNO

Traffic Light

Documented Code

/*
 * This Arduino sketch controls a traffic light system with three LEDs: green,
 * yellow, and red. The green LED stays on for 5 seconds, followed by the
 * yellow LED for 2 seconds, and then the red LED for 5 seconds. This cycle
 * repeats indefinitely.
 */

// Pin definitions
const int greenPin = 3;
const int yellowPin = 2;
const int redPin = 1;

void setup() {
  // Initialize the digital pins as outputs
  pinMode(greenPin, OUTPUT);
  pinMode(yellowPin, OUTPUT);
  pinMode(redPin, OUTPUT);
}

void loop() {
  // Turn on the green LED for 5 seconds
  digitalWrite(greenPin, HIGH);
  delay(5000);
  digitalWrite(greenPin, LOW);

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

  // Turn on the red LED for 5 seconds
  digitalWrite(redPin, HIGH);
  delay(5000);
  digitalWrite(redPin, LOW);
}

Filename: sketch.ino

Description: The code defines three pins corresponding to the green, yellow, and red LEDs of the traffic light module. In the setup() function, these pins are set as outputs. The loop() function then controls the LEDs by turning them on and off in sequence with specified delays to simulate a traffic light.