Traffic Light Control Circuit Documentation
Summary
This document describes a simple traffic light control circuit, which 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 for 5 seconds, yellow light for 2 seconds, and red light 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.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5, SCL, SDA, AREF, D0-D13.
- Purpose: Acts as the central controller for the traffic light system, driving the LEDs and managing the timing of the light changes.
Traffic Light
- Description: A simple traffic light module with three LEDs (green, yellow, red) and a common ground.
- Pins: Green, Yellow, Red, GND.
- Purpose: Represents the traffic light, with each LED corresponding to a light in the traffic signal.
Wiring Details
Arduino UNO
- GND: Connected to the common ground of the Traffic Light.
- D3: Connected to the Green LED of the Traffic Light.
- D2: Connected to the Yellow LED of the Traffic Light.
- D1: Connected to the Red LED of the Traffic Light.
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 with three LEDs: green,
* yellow, and red. The green LED is on for 5 seconds, followed by the yellow
* LED for 2 seconds, and then the red LED for 5 seconds. This cycle repeats
* indefinitely.
*/
// Pin definitions
const int greenLEDPin = 3; // Connected to the Green LED of the Traffic Light
const int yellowLEDPin = 2; // Connected to the Yellow LED of the Traffic Light
const int redLEDPin = 1; // Connected to the Red LED 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 for 5 seconds
digitalWrite(greenLEDPin, HIGH);
delay(5000);
digitalWrite(greenLEDPin, LOW);
// Turn on the yellow LED for 2 seconds
digitalWrite(yellowLEDPin, HIGH);
delay(2000);
digitalWrite(yellowLEDPin, LOW);
// Turn on the red LED for 5 seconds
digitalWrite(redLEDPin, HIGH);
delay(5000);
digitalWrite(redLEDPin, LOW);
}
Filename: sketch.ino
This code is written for the Arduino UNO microcontroller to control the traffic light sequence. The setup() function initializes the digital pins connected to the LEDs as outputs. The loop() function then creates an infinite loop that turns each LED on and off in the sequence described, using the digitalWrite() function to control the state of the LEDs and delay() to manage the timing.
