Traffic Light Controller Circuit Documentation
Summary
This document describes a simple traffic light control system designed using an Arduino UNO microcontroller and a custom traffic light module. The system operates a traffic light with three LEDs (green, yellow, and red) that cycle through a standard traffic light sequence. The green LED is illuminated for 5 seconds, followed by the yellow LED for 2 seconds, and then the red LED for 5 seconds. This sequence repeats indefinitely to simulate a traffic light operation.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Purpose: Acts as the control unit for the traffic light system, driving the LEDs in the sequence.
- Pins Used: GND, D3, D2, D1.
Traffic Light
- Description: A module with three LEDs representing a traffic light.
- Purpose: Displays the traffic light sequence 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 module.
- D3: Connected to the Green LED of the Traffic Light module.
- D2: Connected to the Yellow LED of the Traffic Light module.
- D1: Connected to the Red LED of the Traffic Light module.
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 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;
const int yellowPin = 2;
const int redPin = 1;
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 for the Arduino UNO and is responsible for controlling the traffic light sequence. It sets up the digital pins connected to the LEDs as outputs and then enters a loop where it turns each LED on and off in sequence with appropriate delays to simulate a traffic light.
