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

Arduino UNO Controlled Traffic Light Simulation

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

Traffic Light Control Circuit Documentation

Summary

This document describes a simple traffic light control circuit that is designed to operate a three-color traffic light system. The circuit uses an Arduino UNO microcontroller to cycle through green, yellow, and red LEDs, simulating a traffic light. The green LED is turned on for 5 seconds, followed by the yellow LED for 2 seconds, and then the red LED for 5 seconds. This sequence repeats indefinitely to mimic the operation of a standard traffic light.

Component List

Arduino UNO

Traffic Light

Wiring Details

Arduino UNO

Traffic Light

Documented Code

/*
 * This Arduino sketch controls a traffic light system.
 * The green LED is 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 redPin = 1;    // Connect to the Red LED
const int yellowPin = 2; // Connect to the Yellow LED
const int greenPin = 3;  // Connect to the Green LED

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

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

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

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

Filename: sketch.ino

This code is written for the Arduino UNO microcontroller to control the traffic light. The setup() function initializes the pins connected to the LEDs as outputs. The loop() function then controls the state of each LED, turning them on and off in sequence to simulate a traffic light pattern. The delays between the state changes ensure that each LED is on for the correct duration.