This project implements a traffic light system with a countdown timer using an ATmega32 microcontroller. The system allows normal traffic operation, adjustable red and green light durations, a police mode, and an off mode.
- Normal Mode: The traffic lights operate in a standard cycle (Red → Green → Yellow) while displaying the remaining time on a 7-segment display.
- Adjustable Red Light Duration: Users can modify the red light duration and see real-time updates on the 7-segment display.
- Adjustable Green Light Duration: Users can modify the green light duration similarly.
- Police Mode: The red light blinks, and
"PO"is displayed on the 7-segment display. - Off Mode: Turns off all lights and the 7-segment display.
Graphical Guide for Operating the Circuit
- ATmega32 microcontroller
- 7-segment display (2 digits)
- Push buttons (for mode selection and time adjustment)
- LEDs (Red, Yellow, Green)
| Component | ATmega32 Pin |
|---|---|
| Green LED | PA0 |
| Yellow LED | PA1 |
| Red LED | PA2 |
| 7-Segment (Left - Tens Place) | PORTD (PD0 - PD6) |
| 7-Segment (Right - Ones Place) | PORTC (PC0 - PC6) |
| Normal Mode Button | PB0 |
| Set Red Time Button | PB1 |
| Set Green Time Button | PB2 |
| Police Mode Button | PB3 |
| Off Button | PB4 |
Increase Time (Time+) |
PB5 |
Decrease Time (Time-) |
PB6 |
Press the Normal button (PB0). The traffic lights cycle normally:
🔴 Red → 🟢 Green → 🟡 Yellow
The remaining time for each light is displayed on the 7-segment display.
- Press Set Red (
PB1) to enter red time adjustment mode.- The red LED turns on, and the current red light duration is shown on the 7-segment display.
- Use Time+ (
PB5) to increase the red light duration. - Use Time- (
PB6) to decrease the red light duration. - To save changes, press any other mode button (e.g., Normal, Police, or Set Green).
- Press Set Green (
PB2) to enter green time adjustment mode.- The green LED turns on, and the current green light duration is shown on the 7-segment display.
- Use Time+ (
PB5) to increase the green light duration. - Use Time- (
PB6) to decrease the green light duration. - To save changes, press any other mode button (e.g., Normal, Police, or Set Red).
Press the Police button (PB3).
- The red LED blinks continuously.
"PO"is displayed on the 7-segment display.
Press the Off button (PB4).
- All LEDs and the 7-segment display turn off.
git clone https://github.com/RezaGooner/Traffic-Light-with-Counter.git
cd Traffic-Light-with-CounterUse Atmel Studio, AVR-GCC, or Arduino IDE (if adapted for ATmega) to compile and upload the firmware.
- Open the provided Proteus simulation file.
- Run the simulation and test different modes.
