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

Arduino UNO Traffic Light Controller

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

Traffic Light Control Circuit Documentation

Summary

This document describes a simple traffic light control system implemented using an Arduino UNO microcontroller and a traffic light module with three LEDs (Green, Yellow, and Red). The system operates by cycling through the LEDs in a typical traffic light 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 control system.

Component List

Arduino UNO

Traffic Light

Wiring Details

Arduino UNO

Traffic Light

Documented Code

/*
 * This Arduino sketch controls a traffic light system.
 * The sequence is as follows:
 * - Green LED on for 5 seconds
 * - Yellow LED on for 2 seconds
 * - Red LED on for 5 seconds
 * The sequence repeats indefinitely.
 */

// Pin definitions
const int greenPin = 3; // Arduino pin connected to the green LED of the traffic light
const int yellowPin = 2; // Arduino pin connected to the yellow LED of the traffic light
const int redPin = 1; // Arduino pin connected to the red LED of the traffic light

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

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

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

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

Filename: sketch.ino

Description: The code defines three pins on the Arduino UNO to control 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 to turn on and off in the sequence of a traffic light, with specified delays between the transitions.