Traffic Light Control Circuit Documentation
Summary
This document describes a simple traffic light control circuit that is managed by an Arduino UNO microcontroller. The circuit is designed to control a traffic light module with three LEDs (Red, Yellow, and Green) to simulate a traffic signal with standard timing for each light. The Arduino UNO cycles through the lights in a predetermined sequence: Red for 5 seconds, Yellow for 2 seconds, and Green for 5 seconds. This sequence repeats indefinitely.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0 to A5, SCL, SDA, AREF, D13 to D0.
- Purpose: Acts as the central controller for the traffic light system, driving the LEDs in the sequence.
Traffic Light
- Description: A module with three LEDs representing a traffic light.
- Pins: 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.
- 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
- Green: Connected to D3 on the Arduino UNO.
- Yellow: Connected to D2 on the Arduino UNO.
- Red: Connected to 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.
* The traffic light has three LEDs: Red, Yellow, and Green.
* The sequence is as follows:
* - Red LED on for 5 seconds
* - Yellow LED on for 2 seconds
* - Green LED on for 5 seconds
* The sequence repeats indefinitely.
*/
// Pin definitions
const int redPin = 1;
const int yellowPin = 2;
const int greenPin = 3;
void setup() {
// Initialize the digital pins as outputs
pinMode(redPin, OUTPUT);
pinMode(yellowPin, OUTPUT);
pinMode(greenPin, OUTPUT);
}
void loop() {
// Red LED on for 5 seconds
digitalWrite(redPin, HIGH);
delay(5000);
digitalWrite(redPin, LOW);
// Yellow LED on for 2 seconds
digitalWrite(yellowPin, HIGH);
delay(2000);
digitalWrite(yellowPin, LOW);
// Green LED on for 5 seconds
digitalWrite(greenPin, HIGH);
delay(5000);
digitalWrite(greenPin, LOW);
}
Filename: sketch.ino
Description: The code provided is an Arduino sketch that defines three pins connected to the Red, Yellow, and Green LEDs of the traffic light. In the setup() function, these pins are configured 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.
