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. The circuit uses an Arduino UNO microcontroller to cycle through green, yellow, and red LEDs, which simulate a traffic light. The sequence of operation is as follows:
- The green LED is turned on for 5 seconds.
- The green LED is turned off, and the yellow LED is turned on for 2 seconds.
- The yellow LED is turned off, and the red LED is turned on for 5 seconds.
- The red LED is turned off, and the sequence repeats indefinitely.
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 correct 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 light system being controlled by the Arduino.
- Pins: Green, Yellow, Red, GND.
Wiring Details
Arduino UNO
- GND: Connected to the GND pin of the Traffic Light.
- D3: Connected to the Green pin of the Traffic Light.
- D2: Connected to the Yellow pin of the Traffic Light.
- D1: Connected to the Red pin 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 GND on the Arduino UNO.
Documented Code
/*
* This Arduino sketch controls a traffic light system.
* The sequence is as follows:
* - Green LED on for 5 seconds
* - Yellow LED on for 2 seconds
* - Red LED on for 5 seconds
* This sequence repeats indefinitely.
*/
// Pin definitions
const int greenPin = 3; // Arduino pin connected to the green LED of the Traffic Light
const int yellowPin = 2; // Arduino pin connected to the yellow LED of the Traffic Light
const int redPin = 1; // Arduino pin connected to the red LED of the Traffic Light
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);
}
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 an infinite loop where it turns each LED on and off in the sequence described above. The delay() function is used to keep each LED on for the specified duration.
