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 using an Arduino UNO microcontroller. The circuit controls three LEDs representing the green, yellow, and red lights of a traffic signal. The Arduino UNO cycles through the lights in a typical traffic light sequence: green light for 5 seconds, yellow light for 2 seconds, and red light for 5 seconds. This sequence repeats indefinitely.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins Used: GND, D2, D3, D4.
- Purpose: Acts as the central controller for the traffic light system, driving the LEDs and managing the timing of the light sequence.
Traffic Light
- Description: A simple representation of a traffic light with three LEDs.
- Pins Used: Green, Yellow, Red, GND.
- Purpose: Displays the traffic light sequence as controlled by the Arduino UNO.
Wiring Details
Arduino UNO
- GND: Connected to the GND pin of the Traffic Light to establish a common ground.
- D2: Connected to the Red LED of the Traffic Light.
- D3: Connected to the Yellow LED of the Traffic Light.
- D4: Connected to the Green LED of the Traffic Light.
Traffic Light
- Green: Connected to pin D4 on the Arduino UNO.
- Yellow: Connected to pin D3 on the Arduino UNO.
- Red: Connected to pin D2 on the Arduino UNO.
- GND: Connected to the GND pin on the Arduino UNO to complete the circuit.
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 = 4; // Arduino pin connected to the green LED
const int yellowPin = 3; // Arduino pin connected to the yellow LED
const int redPin = 2; // Arduino pin connected to the red LED
void setup() {
// Initialize the digital pins as outputs
pinMode(greenPin, OUTPUT);
pinMode(yellowPin, OUTPUT);
pinMode(redPin, OUTPUT);
}
void loop() {
// Turn on the green LED
digitalWrite(greenPin, HIGH);
delay(5000); // Wait for 5 seconds
digitalWrite(greenPin, LOW);
// Turn on the yellow LED
digitalWrite(yellowPin, HIGH);
delay(2000); // Wait for 2 seconds
digitalWrite(yellowPin, LOW);
// Turn on the red LED
digitalWrite(redPin, HIGH);
delay(5000); // Wait for 5 seconds
digitalWrite(redPin, LOW);
}
The code is written in Arduino's sketch language and is intended to be uploaded to the Arduino UNO microcontroller. It defines three pins as outputs corresponding to the green, yellow, and red LEDs of the traffic light. The setup() function initializes these pins as outputs. The loop() function then controls the state of each LED, turning them on and off in sequence with appropriate delays to simulate a traffic light.
