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 Control Circuit Documentation

Summary

This document describes a simple traffic light control circuit, which is designed to operate a three-light traffic signal with standard green, yellow, and red lights. The circuit is controlled by an Arduino UNO microcontroller, which cycles through the lights in a predetermined sequence: green light for 5 seconds, yellow light for 2 seconds, and red light for 5 seconds. This sequence repeats indefinitely to simulate a traffic light system.

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 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 greenLEDPin = 3; // Connected to the Green LED of the Traffic Light
const int yellowLEDPin = 2; // Connected to the Yellow LED of the Traffic Light
const int redLEDPin = 1; // Connected to the Red LED of the Traffic Light

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

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

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

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

Filename: sketch.ino

This code is written for the Arduino UNO microcontroller to control the traffic light sequence. The setup() function initializes the digital pins connected to the LEDs as outputs. The loop() function then creates an infinite loop that turns each LED on and off in the sequence described, using the digitalWrite() function to control the state of the LEDs and delay() to manage the timing.