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 system using an Arduino UNO microcontroller and a traffic light module. The system operates a sequence of lights: red, yellow, and green, each for a specific duration. The Arduino UNO controls the traffic light by turning on and off the respective LEDs in a predefined sequence. The circuit also includes a joystick module, although it is not connected in the current configuration.

Component List

Arduino UNO

Traffic Light

Joystick Module

Wiring Details

Arduino UNO

Traffic Light

Joystick Module

Documented Code

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

// Pin definitions
const int redLedPin = 1;    // Red LED connected to digital pin 1
const int yellowLedPin = 2; // Yellow LED connected to digital pin 2
const int greenLedPin = 3;  // Green LED connected to digital pin 3

void setup() {
  // Initialize the LED pins as outputs
  pinMode(redLedPin, OUTPUT);
  pinMode(yellowLedPin, OUTPUT);
  pinMode(greenLedPin, OUTPUT);
}

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

  // Turn on the Yellow LED
  digitalWrite(yellowLedPin, HIGH);
  delay(2000); // Wait for 2 seconds
  digitalWrite(yellowLedPin, LOW);

  // Turn on the Green LED
  digitalWrite(greenLedPin, HIGH);
  delay(5000); // Wait for 5 seconds
  digitalWrite(greenLedPin, LOW);
}

Filename: sketch.ino

This code is responsible for controlling the traffic light sequence. It initializes the digital pins connected to the LEDs as outputs and then enters a loop where it turns each LED on and off in sequence with delays to represent the duration each light is on. The red LED is on for 5 seconds, followed by the yellow LED for 2 seconds, and the green LED for 5 seconds. This cycle repeats indefinitely.