Traffic Light Control Circuit Documentation
Summary
This circuit is designed to simulate a traffic light system using an Arduino UNO microcontroller and a custom traffic light module. The system operates by sequentially illuminating green, yellow, and red LEDs to mimic the behavior of a standard traffic light. The green LED is activated for 5 seconds, followed by the yellow LED for 2 seconds, and finally, the red LED for 5 seconds. This cycle repeats indefinitely to demonstrate a simple traffic light control mechanism.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Purpose: Acts as the central control unit for the traffic light system, driving the LEDs and managing timing.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5, SCL, SDA, AREF, D0-D13
Traffic Light
- Description: A module with three LEDs representing the green, yellow, and red lights of a traffic signal.
- Purpose: To display the traffic light sequence controlled by the Arduino UNO.
- Pins: Green, Yellow, Red, GND
Wiring Details
Arduino UNO
- GND is connected to the Traffic Light's GND pin to establish a common ground.
- D3 is connected to the Traffic Light's Green pin to control the green LED.
- D2 is connected to the Traffic Light's Yellow pin to control the yellow LED.
- D1 is connected to the Traffic Light's Red pin to control the red LED.
Traffic Light
- Green is connected to Arduino UNO's D3 pin.
- Yellow is connected to Arduino UNO's D2 pin.
- Red is connected to Arduino UNO's D1 pin.
- GND is connected to Arduino UNO's GND pin.
Documented Code
/*
* This Arduino sketch controls a traffic light system with three LEDs: green,
* yellow, and red. The green LED stays 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 greenPin = 3; // Arduino UNO D3 pin
const int yellowPin = 2; // Arduino UNO D2 pin
const int redPin = 1; // Arduino UNO D1 pin
void setup() {
// Initialize the digital pins as outputs
pinMode(greenPin, OUTPUT);
pinMode(yellowPin, OUTPUT);
pinMode(redPin, OUTPUT);
}
void loop() {
// Green LED on for 5 seconds
digitalWrite(greenPin, HIGH);
delay(5000);
digitalWrite(greenPin, LOW);
// Yellow LED on for 2 seconds
digitalWrite(yellowPin, HIGH);
delay(2000);
digitalWrite(yellowPin, LOW);
// Red LED on for 5 seconds
digitalWrite(redPin, HIGH);
delay(5000);
digitalWrite(redPin, LOW);
}
Filename: sketch.ino
Description: The code is written for the Arduino UNO microcontroller. It initializes three digital pins as outputs to control the green, yellow, and red LEDs of the traffic light module. The loop() function turns on each LED in sequence with specified delays to create the traffic light effect.
