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 the green, yellow, and red LEDs of a traffic light, illuminating each color for a specific duration to simulate a traffic signal operation. The green LED is lit for 5 seconds, followed by the yellow LED for 2 seconds, and then the red LED for 5 seconds. This sequence repeats indefinitely.
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 changes.
- Pins Used: GND, D3, D2, D1.
Traffic Light
- Description: A simple traffic light module with three LEDs (Green, Yellow, Red).
- Purpose: Represents the traffic light being controlled by the Arduino UNO.
- Pins Used: 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 to receive control signals for the green LED.
- Yellow: Connected to pin D2 on the Arduino UNO to receive control signals for the yellow LED.
- Red: Connected to pin D1 on the Arduino UNO to receive control signals for the red LED.
- GND: Connected to the GND pin on the Arduino UNO to complete the circuit.
Documented Code
/*
* This Arduino sketch controls a traffic light system.
* 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 greenPin = 3; // Arduino pin connected to the green LED
const int yellowPin = 2; // Arduino pin connected to the yellow LED
const int redPin = 1; // 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 provided is an Arduino sketch that defines the pin connections and contains the logic to control the traffic light sequence. The setup() function initializes the pins connected to the LEDs as outputs. The loop() function contains the main logic to turn on each LED in sequence with the specified delays, creating the traffic light effect.
