Traffic Light Control Circuit Documentation
Summary
This document describes a simple traffic light control circuit that is designed to operate a three-color traffic light system using an Arduino UNO microcontroller. The circuit controls three LEDs (representing the green, yellow, and red lights of a traffic light) by turning them on and off in a specific sequence to mimic the operation of a standard traffic light. The Arduino UNO is programmed to switch the red LED on for 5 seconds, followed by the yellow LED for 2 seconds, and then the green LED for 5 seconds. This sequence repeats indefinitely.
Component List
Traffic Light
- Component Name: Traffic Light
- Pins: Green, Yellow, Red, GND
- Description: A representation of a traffic light with three LEDs.
- Purpose: To simulate the traffic light functionality by lighting up the respective LEDs.
Arduino UNO
- Component Name: Arduino UNO
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5, SCL, SDA, AREF, D0-D13
- Description: A microcontroller board based on the ATmega328P.
- Purpose: To control the traffic light LEDs by providing the necessary logic and timing.
Wiring Details
Traffic Light
- Green LED: Connected to Arduino UNO pin D3.
- Yellow LED: Connected to Arduino UNO pin D2.
- Red LED: Connected to Arduino UNO pin D1.
- GND: Connected to Arduino UNO GND pin.
Arduino UNO
- 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.
- GND: Common ground with the Traffic Light.
Documented Code
/*
* This Arduino sketch controls a traffic light system with three LEDs: red,
* yellow, and green. The red LED is on for 5 seconds, followed by the yellow
* LED for 2 seconds, and then the green LED for 5 seconds. This cycle repeats
* indefinitely.
*/
// Pin definitions
const int redPin = 1; // Red LED connected to pin D1
const int yellowPin = 2; // Yellow LED connected to pin D2
const int greenPin = 3; // Green LED connected to pin D3
void setup() {
// Initialize the digital pins as outputs
pinMode(redPin, OUTPUT);
pinMode(yellowPin, OUTPUT);
pinMode(greenPin, OUTPUT);
}
void loop() {
// Red LED on for 5 seconds
digitalWrite(redPin, HIGH);
delay(5000);
digitalWrite(redPin, LOW);
// Yellow LED on for 2 seconds
digitalWrite(yellowPin, HIGH);
delay(2000);
digitalWrite(yellowPin, LOW);
// Green LED on for 5 seconds
digitalWrite(greenPin, HIGH);
delay(5000);
digitalWrite(greenPin, LOW);
}
Filename: sketch.ino
This code is written for the Arduino UNO microcontroller to control the traffic light system. The setup() function initializes the 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, with specified delays between the transitions.
