Traffic Light Control System Documentation
Summary
The circuit described in this documentation is designed to control a traffic light system using an Arduino UNO microcontroller. The traffic light system consists of three LEDs (Green, Yellow, and Red) that simulate 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 sequence is as follows:
- The Green LED is on for 5 seconds.
- The Yellow LED is on for 2 seconds.
- The Red LED is on for 5 seconds.
This sequence repeats indefinitely to simulate a traffic light control system.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5, SCL, SDA, AREF, D0-D13
- 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 module with three LEDs representing a traffic light.
- Pins: Green, Yellow, Red, GND
- Purpose: Represents the traffic light, with each LED corresponding to the green, yellow, and red lights of a standard traffic signal.
Joystick Module
- Description: An input device with an analog stick and a push button.
- Pins: SW, VRY, VRX, VCC, GND
- Purpose: Not directly used in the traffic light control system as per the provided information.
Wiring Details
Arduino UNO
- GND connected to Traffic Light GND
- D3 connected to Traffic Light Green LED
- D2 connected to Traffic Light Yellow LED
- D1 connected to Traffic Light Red LED
Traffic Light
- Green connected to Arduino UNO D3
- Yellow connected to Arduino UNO D2
- Red connected to Arduino UNO D1
- GND connected to Arduino UNO GND
Joystick Module
- No connections specified for the traffic light control system.
Documented Code
/*
* This Arduino sketch controls a traffic light system.
* The traffic light has three LEDs: Green, Yellow, and Red.
* The sequence is as follows:
* - Green LED is on for 5 seconds
* - Yellow LED is on for 2 seconds
* - Red LED is on for 5 seconds
* This sequence 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() {
// 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);
}
The code provided is an Arduino sketch written in C++ for the Arduino IDE. It defines three pins connected to the respective LEDs of the traffic light and sets them as outputs in the setup() function. The loop() function then controls the state of each LED to create the traffic light sequence. The comments within the code provide additional context and explanation of the code's functionality.
