https://github.com/rezagooner/traffic-light-with-counter
This repository contains C code(Code vision file) and Proteus simulation files for a traffic light control system. The system includes three lights (red, yellow, and green) and a two-digit counter to display the remaining time for each light. The duration of each light can be adjusted in real-time using buttons.
https://github.com/rezagooner/traffic-light-with-counter
arduino atmega32 cprogramming electronics embeddedsystems ledcontrol microcontroller proteuside proteussimulation simulation timers trafficcontrol trafficlight
Last synced: about 1 month ago
JSON representation
This repository contains C code(Code vision file) and Proteus simulation files for a traffic light control system. The system includes three lights (red, yellow, and green) and a two-digit counter to display the remaining time for each light. The duration of each light can be adjusted in real-time using buttons.
- Host: GitHub
- URL: https://github.com/rezagooner/traffic-light-with-counter
- Owner: RezaGooner
- Created: 2025-03-06T22:52:36.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-07T00:16:25.000Z (about 1 year ago)
- Last Synced: 2025-03-07T00:19:21.757Z (about 1 year ago)
- Topics: arduino, atmega32, cprogramming, electronics, embeddedsystems, ledcontrol, microcontroller, proteuside, proteussimulation, simulation, timers, trafficcontrol, trafficlight
- Language: Assembly
- Homepage:
- Size: 111 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
---
# Traffic Light with Counter
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.
## 🚦 Features
- **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
## 🛠️ Hardware Components
- **ATmega32** microcontroller
- **7-segment display (2 digits)**
- **Push buttons** (for mode selection and time adjustment)
- **LEDs (Red, Yellow, Green)**
---
## 🔧 Circuit Connections
| 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` |
---
## 🎮 How to Use
### **1️⃣ Normal Mode**
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**.
---
### **2️⃣ Adjusting Red Light Duration**
1. 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**.
2. Use **Time+ (`PB5`)** to **increase** the red light duration.
3. Use **Time- (`PB6`)** to **decrease** the red light duration.
4. To **save changes**, press any other mode button (e.g., **Normal, Police, or Set Green**).
---
### **3️⃣ Adjusting Green Light Duration**
1. 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**.
2. Use **Time+ (`PB5`)** to **increase** the green light duration.
3. Use **Time- (`PB6`)** to **decrease** the green light duration.
4. To **save changes**, press any other mode button (e.g., **Normal, Police, or Set Red**).
---
### **4️⃣ Police Mode**
Press the **Police** button (`PB3`).
- The **red LED blinks continuously**.
- `"PO"` is displayed on the **7-segment display**.
---
### **5️⃣ Off Mode**
Press the **Off** button (`PB4`).
- **All LEDs and the 7-segment display turn off.**
---
## 🚀 Getting Started
### **1️⃣ Clone the Repository**
```bash
git clone https://github.com/RezaGooner/Traffic-Light-with-Counter.git
cd Traffic-Light-with-Counter
```
### **2️⃣ Compile & Upload the Code**
Use **Atmel Studio**, **AVR-GCC**, or **Arduino IDE** (if adapted for ATmega) to compile and upload the firmware.
### **3️⃣ Simulate in Proteus**
- Open the provided **Proteus** simulation file.
- Run the simulation and test different modes.
---