Traffic Light Controller Circuit Documentation
Summary
This document describes a simple traffic light controller circuit that uses an Arduino UNO microcontroller to cycle through a traffic light sequence. The sequence follows the standard traffic light pattern: Green -> Yellow -> Red -> Green. The circuit consists of an Arduino UNO board and a traffic light module with three LEDs (Red, Yellow, and Green). The Arduino UNO controls the LEDs via its digital output pins.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins Used: GND, D1, D2, D3.
- Purpose: Acts as the central controller for the traffic light sequence.
Traffic Light
- Description: A module with three LEDs representing a traffic light.
- Pins Used: Green, Yellow, Red, GND.
- Purpose: Displays the traffic light sequence 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 the D3 pin of the Arduino UNO.
- Yellow: Connected to the D2 pin of the Arduino UNO.
- Red: Connected to the D1 pin of the Arduino UNO.
- GND: Connected to the GND pin of the Arduino UNO.
Documented Code
/*
* Traffic Light LED Control
* This Arduino sketch controls a traffic light with three LEDs (Red, Yellow,
* and Green) connected to an Arduino UNO. The LEDs are connected to digital
* pins D1, D2, and D3 respectively. The sketch will cycle through the traffic
* light sequence: Green -> Yellow -> Red -> Green.
*/
// Pin definitions
const int redPin = 1; // Red LED connected to digital pin D1
const int yellowPin = 2; // Yellow LED connected to digital pin D2
const int greenPin = 3; // Green LED connected to digital pin D3
// Timing constants
const int greenTime = 5000; // Green light duration in milliseconds
const int yellowTime = 2000; // Yellow light duration in milliseconds
const int redTime = 5000; // Red light duration in milliseconds
void setup() {
// Initialize the digital pins as outputs
pinMode(redPin, OUTPUT);
pinMode(yellowPin, OUTPUT);
pinMode(greenPin, OUTPUT);
}
void loop() {
// Green light on, others off
digitalWrite(greenPin, HIGH);
digitalWrite(yellowPin, LOW);
digitalWrite(redPin, LOW);
delay(greenTime);
// Yellow light on, others off
digitalWrite(greenPin, LOW);
digitalWrite(yellowPin, HIGH);
digitalWrite(redPin, LOW);
delay(yellowTime);
// Red light on, others off
digitalWrite(greenPin, LOW);
digitalWrite(yellowPin, LOW);
digitalWrite(redPin, HIGH);
delay(redTime);
}
Filename: sketch.ino
Description: The code provided is an Arduino sketch that defines the pin connections and timing for the traffic light sequence. It initializes the pins connected to the LEDs as outputs and then enters a loop where it turns on each LED in sequence with appropriate delays to simulate a traffic light.
