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

Arduino-Controlled Traffic Light System

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

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 using an Arduino UNO microcontroller. The circuit controls three LEDs (representing the green, yellow, and red lights of a traffic light) by turning them on and off in a specific sequence to mimic the operation of a standard traffic light. The Arduino UNO is programmed to switch the red LED on for 5 seconds, followed by the yellow LED for 2 seconds, and then the green LED for 5 seconds. This sequence repeats indefinitely.

Component List

Traffic Light

Arduino UNO

Wiring Details

Traffic Light

Arduino UNO

Documented Code

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

// Pin definitions
const int redPin = 1;    // Red LED connected to pin D1
const int yellowPin = 2;  // Yellow LED connected to pin D2
const int greenPin = 3;   // Green LED connected to pin D3

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

void loop() {
  // Red LED on for 5 seconds
  digitalWrite(redPin, HIGH);
  delay(5000);
  digitalWrite(redPin, LOW);
  
  // Yellow LED on for 2 seconds
  digitalWrite(yellowPin, HIGH);
  delay(2000);
  digitalWrite(yellowPin, LOW);
  
  // Green LED on for 5 seconds
  digitalWrite(greenPin, HIGH);
  delay(5000);
  digitalWrite(greenPin, LOW);
}

Filename: sketch.ino

This code is written for the Arduino UNO microcontroller to control the traffic light system. The setup() function initializes the 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, with specified delays between the transitions.