Traffic Light Control Circuit Documentation
Summary
This document describes a simple traffic light control system implemented using an Arduino UNO microcontroller and a traffic light module with three LEDs (Green, Yellow, and Red). The system operates by cycling through the LEDs in a typical traffic light sequence: green light for 5 seconds, yellow light for 2 seconds, and red light 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 Used: GND, D3, D2, D1.
- Purpose: Acts as the control unit for the traffic light system, driving the LEDs in the sequence programmed in the embedded code.
Traffic Light
- Description: A module with three LEDs representing a traffic light.
- Pins Used: Green, Yellow, Red, GND.
- Purpose: Represents the traffic light, with each LED being controlled by the Arduino to display the traffic signal.
Wiring Details
Arduino UNO
- GND: Connected to the GND pin of the Traffic Light module.
- D3: Connected to the Green LED pin of the Traffic Light module.
- D2: Connected to the Yellow LED pin of the Traffic Light module.
- D1: Connected to the Red LED pin 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.
* The sequence is as follows:
* - Green LED on for 5 seconds
* - Yellow LED on for 2 seconds
* - Red LED on for 5 seconds
* The 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
Description: The code defines three pins on the Arduino UNO to control the green, yellow, and red LEDs of the traffic light module. In the setup() function, these pins are set as outputs. The loop() function then controls the LEDs to turn on and off in the sequence of a traffic light, with specified delays between the transitions.
