Traffic Light Controller Circuit Documentation
Summary
This circuit is designed to control a traffic light system using an Arduino UNO microcontroller. The system operates a set of three LEDs that represent the green, yellow, and red lights of a traffic signal. The Arduino UNO is programmed to switch these LEDs on and off in a specific sequence to mimic the operation of a standard traffic light. 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 cycle repeats indefinitely to simulate the traffic light operation.
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 sequence.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5, SCL, SDA, AREF, D13-D0.
Traffic Light
- Description: A simple traffic light module with three LEDs (Green, Yellow, Red).
- Purpose: Represents the traffic signal lights controlled by the Arduino UNO.
- Pins: Green, Yellow, Red, GND.
Wiring Details
Arduino UNO
- GND: Connected to the GND pin of the Traffic Light.
- 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.
Traffic Light
- GND: Connected to the GND pin of the Arduino UNO.
- Green: Connected to pin D3 of the Arduino UNO.
- Yellow: Connected to pin D2 of the Arduino UNO.
- Red: Connected to pin D1 of 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 for 5 seconds
digitalWrite(greenPin, HIGH);
delay(5000);
digitalWrite(greenPin, LOW);
// Turn on the yellow LED for 2 seconds
digitalWrite(yellowPin, HIGH);
delay(2000);
digitalWrite(yellowPin, LOW);
// Turn on the red LED for 5 seconds
digitalWrite(redPin, HIGH);
delay(5000);
digitalWrite(redPin, LOW);
}
Filename: sketch.ino
This code is responsible for controlling the traffic light sequence. It initializes the digital pins connected to the LEDs as outputs and then enters a loop where it turns each LED on and off in the sequence described in the summary. The delay() function is used to keep each LED on for the desired amount of time.
