A traffic light is a signaling device that uses colored lights—red, yellow, and green—to control traffic flow at intersections. These lights indicate stop, caution, and go, respectively, ensuring safe and orderly movement of vehicles and pedestrians. Traffic lights are widely used in urban areas, highways, and pedestrian crossings to manage traffic efficiently and reduce accidents.
Below is a typical pin configuration for a 3-light traffic light module:
Pin | Name | Description |
---|---|---|
1 | Red LED (+) | Positive terminal for the red LED (connect to microcontroller or power source) |
2 | Yellow LED (+) | Positive terminal for the yellow LED (connect to microcontroller or power source) |
3 | Green LED (+) | Positive terminal for the green LED (connect to microcontroller or power source) |
4 | Common (-) | Common ground for all LEDs (connect to ground of the circuit) |
Below is an example of how to control a traffic light module using an Arduino UNO:
// Pin assignments for the traffic light module
const int redPin = 8; // Red LED connected to digital pin 8
const int yellowPin = 9; // Yellow LED connected to digital pin 9
const int greenPin = 10; // Green LED connected to digital pin 10
void setup() {
// Set the LED pins as outputs
pinMode(redPin, OUTPUT);
pinMode(yellowPin, OUTPUT);
pinMode(greenPin, OUTPUT);
}
void loop() {
// Red light ON for 10 seconds
digitalWrite(redPin, HIGH);
digitalWrite(yellowPin, LOW);
digitalWrite(greenPin, LOW);
delay(10000); // Wait for 10 seconds
// Yellow light ON for 3 seconds
digitalWrite(redPin, LOW);
digitalWrite(yellowPin, HIGH);
digitalWrite(greenPin, LOW);
delay(3000); // Wait for 3 seconds
// Green light ON for 10 seconds
digitalWrite(redPin, LOW);
digitalWrite(yellowPin, LOW);
digitalWrite(greenPin, HIGH);
delay(10000); // Wait for 10 seconds
}
LEDs Not Lighting Up:
Flickering LEDs:
Incorrect LED Sequence:
Overheating:
Q: Can I use the traffic light module with a 3.3V microcontroller?
A: Yes, but ensure the LEDs can operate at 3.3V. If not, use a transistor or MOSFET to drive the LEDs with a higher voltage.
Q: How do I calculate the resistor value for the LEDs?
A: Use the formula:
R = (V_supply - V_forward) / I_forward
Where V_supply
is the power supply voltage, V_forward
is the LED's forward voltage, and I_forward
is the desired current (e.g., 20mA).
Q: Can I use this module outdoors?
A: Most traffic light modules are designed for indoor use. For outdoor applications, ensure the module is weatherproof or housed in a protective enclosure.