Traffic Light Control Circuit Documentation
Summary
This document describes a simple traffic light control circuit that is designed to operate a three-light traffic signal with standard green, yellow, and red lights. The circuit is controlled by an Arduino UNO microcontroller, which cycles through the lights in a predetermined sequence: green light on for 5 seconds, yellow light on for 2 seconds, and red light on for 5 seconds. This sequence repeats indefinitely to simulate a traffic light system.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Purpose: Acts as the central controller for the traffic light system, driving the LEDs and managing the timing of the light sequence.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5, SCL, SDA, AREF, D13-D0.
Traffic Light
- Description: A simple traffic light module with three LEDs representing the green, yellow, and red lights.
- Purpose: To display the traffic light sequence as controlled by the Arduino UNO.
- Pins: Green, Yellow, Red, GND.
Wiring Details
Arduino UNO
- GND: Connected to the GND pin of the Traffic Light to establish a common ground.
- D3: Connected to the Green pin of the Traffic Light to control the green LED.
- D2: Connected to the Yellow pin of the Traffic Light to control the yellow LED.
- D1: Connected to the Red pin of the Traffic Light to control the red LED.
Traffic Light
- Green: Connected to pin D3 on the Arduino UNO.
- Yellow: Connected to pin D2 on the Arduino UNO.
- Red: Connected to pin D1 on the Arduino UNO.
- GND: Connected to the GND pin on the Arduino UNO.
Documented Code
/*
* This Arduino sketch controls a traffic light system.
* The traffic light has three LEDs: Green, Yellow, and Red.
* The sequence is as follows:
* - Green LED is on for 5 seconds
* - Yellow LED is on for 2 seconds
* - Red LED is on for 5 seconds
* This sequence repeats indefinitely.
*/
// Pin definitions
const int greenLEDPin = 3; // Arduino pin connected to the green light of the traffic light
const int yellowLEDPin = 2; // Arduino pin connected to the yellow light of the traffic light
const int redLEDPin = 1; // Arduino pin connected to the red light of the traffic light
void setup() {
// Initialize the LED pins as outputs
pinMode(greenLEDPin, OUTPUT);
pinMode(yellowLEDPin, OUTPUT);
pinMode(redLEDPin, OUTPUT);
}
void loop() {
// Turn on the Green LED
digitalWrite(greenLEDPin, HIGH);
delay(5000); // Wait for 5 seconds
digitalWrite(greenLEDPin, LOW);
// Turn on the Yellow LED
digitalWrite(yellowLEDPin, HIGH);
delay(2000); // Wait for 2 seconds
digitalWrite(yellowLEDPin, LOW);
// Turn on the Red LED
digitalWrite(redLEDPin, HIGH);
delay(5000); // Wait for 5 seconds
digitalWrite(redLEDPin, LOW);
}
Filename: sketch.ino
This code is responsible for controlling the traffic light sequence. It initializes the pins connected to the LEDs as outputs and then enters an infinite loop where it turns each LED on and off in sequence with appropriate delays to simulate a traffic light.
