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

Arduino UNO Controlled Traffic Light Simulator

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

Traffic Light Controller Circuit Documentation

Summary

This document describes a simple traffic light control system designed using an Arduino UNO microcontroller and a custom traffic light module. The system operates a traffic light sequence with three stages: green, yellow, and red. The green light is active for 5 seconds, followed by the yellow light for 2 seconds, and the 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 with three LEDs: green,
 * yellow, and red. The green LED stays on for 5 seconds, followed by the
 * yellow LED for 2 seconds, and finally the red LED for 5 seconds. This
 * sequence 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
  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

Description: The code provided is an Arduino sketch that defines the pin connections to the traffic light module and contains the logic to cycle through the green, yellow, and red lights. The setup() function initializes the pins connected to the LEDs as outputs. The loop() function controls the state of each LED, turning them on and off in sequence with specified delays to create the traffic light effect.