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

Summary

This document describes a simple traffic light controller circuit that uses an Arduino UNO microcontroller to cycle through a traffic light sequence. The sequence follows the standard traffic light pattern: Green -> Yellow -> Red -> Green. The circuit consists of an Arduino UNO board and a traffic light module with three LEDs (Red, Yellow, and Green). The Arduino UNO controls the LEDs via its digital output pins.

Component List

Arduino UNO

Traffic Light

Wiring Details

Arduino UNO

Traffic Light

Documented Code

/*
 * Traffic Light LED Control
 * This Arduino sketch controls a traffic light with three LEDs (Red, Yellow,
 * and Green) connected to an Arduino UNO. The LEDs are connected to digital
 * pins D1, D2, and D3 respectively. The sketch will cycle through the traffic
 * light sequence: Green -> Yellow -> Red -> Green.
 */

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

// Timing constants
const int greenTime = 5000;  // Green light duration in milliseconds
const int yellowTime = 2000; // Yellow light duration in milliseconds
const int redTime = 5000;    // Red light duration in milliseconds

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

void loop() {
  // Green light on, others off
  digitalWrite(greenPin, HIGH);
  digitalWrite(yellowPin, LOW);
  digitalWrite(redPin, LOW);
  delay(greenTime);

  // Yellow light on, others off
  digitalWrite(greenPin, LOW);
  digitalWrite(yellowPin, HIGH);
  digitalWrite(redPin, LOW);
  delay(yellowTime);

  // Red light on, others off
  digitalWrite(greenPin, LOW);
  digitalWrite(yellowPin, LOW);
  digitalWrite(redPin, HIGH);
  delay(redTime);
}

Filename: sketch.ino

Description: The code provided is an Arduino sketch that defines the pin connections and timing for the traffic light sequence. It initializes the pins connected to the LEDs as outputs and then enters a loop where it turns on each LED in sequence with appropriate delays to simulate a traffic light.