https://github.com/rezagooner/timer-4digit-7segment
This project is a Digital Clock that displays time in minutes and seconds on a 4-digit 7-segment display. It uses the ATmega32 microcontroller, a BCD to 7-Segment Decoder (IC 7447), and the Multiplexing technique.
https://github.com/rezagooner/timer-4digit-7segment
7segment 7segmentdisplay atmega32 bdc cprogramming electronics electronicsproject embeddedsystems hardwaredesign ic7448 opensource timedisplay
Last synced: 8 months ago
JSON representation
This project is a Digital Clock that displays time in minutes and seconds on a 4-digit 7-segment display. It uses the ATmega32 microcontroller, a BCD to 7-Segment Decoder (IC 7447), and the Multiplexing technique.
- Host: GitHub
- URL: https://github.com/rezagooner/timer-4digit-7segment
- Owner: RezaGooner
- License: mit
- Created: 2025-03-11T19:38:53.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-11T20:20:17.000Z (about 1 year ago)
- Last Synced: 2025-03-11T21:20:58.270Z (about 1 year ago)
- Topics: 7segment, 7segmentdisplay, atmega32, bdc, cprogramming, electronics, electronicsproject, embeddedsystems, hardwaredesign, ic7448, opensource, timedisplay
- Language: Assembly
- Homepage:
- Size: 71.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Display Time on a 4-Digit 7-Segment Display Using ATmega32 and BCD to 7-Segment Decoder (IC 7447)
This project is a simple digital clock that displays time on a 4-digit 7-segment display. It is implemented using the **ATmega32** microcontroller, a **BCD to 7-Segment Decoder (IC 7447)**, and the **Multiplexing** technique.
---
## Table of Contents
- [Introduction](#introduction)
- [Components Required](#components-required)
- [How It Works](#how-it-works)
- [Hardware Connections](#hardware-connections)
- [How to Run the Project](#how-to-run-the-project)
- [Programming](#programming)
---
## Introduction
This project is a simple digital clock that displays minutes and seconds on a 4-digit 7-segment display. The **ATmega32** microcontroller generates BCD (Binary-Coded Decimal) values, which are then converted to the appropriate signals for the 7-segment display using the **BCD to 7-Segment Decoder (IC 7447)**. The **Multiplexing** technique is employed to display all digits simultaneously.
---
## Components Required
- **ATmega32** microcontroller
- 4-digit 7-segment display (Common Cathode)
- BCD to 7-Segment Decoder (IC 7447)
- NPN transistors (e.g., 2N2222 or BC547) (4 pieces)
- 5V power supply
---
## How It Works

In this project, time is calculated in minutes and seconds and displayed on the 7-segment display. The **ATmega32** generates BCD values for each digit, which are then sent to the **BCD to 7-Segment Decoder (IC 7447)**. The decoder converts the BCD values into the appropriate signals to drive the 7-segment display.
Each digit is activated one by one and quickly turned on and off to create the illusion that all digits are lit simultaneously. This process is achieved using the **Multiplexing** technique.
The time increments every second, and after reaching 60 seconds, the minutes increase. If the minutes reach 60, they reset to zero.
---
## Hardware Connections

### Port C (PORTC):
- Port C is used to send BCD values to the **BCD to 7-Segment Decoder (IC 7447)**.
- Each BCD value corresponds to a digit (0-9).
| 7448 Pin | Microcontroller Port |
|---------|----------------------|
| A | PC0 |
| B | PC1 |
| C | PC2 |
| D | PC3 |
### Port D (PORTD):
- Port D is used to control the common cathodes of each digit.
- Each pin of Port D is connected to the base of an NPN transistor.
- The collector of the transistor is connected to the common cathode of a digit on the 7-segment display.
- The emitter of the transistor is connected to ground (GND).
| input Not Gates | Microcontroller Port |
|-------------------|----------------------|
| Gate 1 | PD0 |
| Gate 2 | PD1 |
| Gate 3 | PD2 |
| Gate 4 | PD3 |
| 7-Segment Cathode | output Not Gates |
|-------------------|----------------------|
| Digit 1 Cathode | Gate 1 |
| Digit 2 Cathode | Gate 2 |
| Digit 3 Cathode | Gate 3 |
| Digit 4 Cathode | Gate 4 |
### BCD to 7-Segment Decoder (IC 7447):
- The BCD inputs (A, B, C, D) are connected to Port C of the microcontroller.
- The 7-segment outputs (a, b, c, d, e, f, g) are connected to the corresponding segments of the 7-segment display.
| IC 7447 Pin | 7-Segment Pin |
|-------------|---------------|
| QA | A |
| QB | B |
| QC | C |
| QD | D |
| QE | E |
| QF | F |
| QG | G |
| IC 7447 Pin | Connected to |
|-------------|---------------|
| LT | VCC |
| RBI | VCC |
| BI/RBO | VCC |
---
## How to Run the Project
1. **Hardware Connections**: Connect the components as per the tables above.
2. Compile the project code in a suitable programming environment (e.g., CodeVision or Atmel Studio).
3. Program the generated HEX file onto the ATmega32 microcontroller.
4. Power on the circuit and observe the time displayed on the 7-segment display.

---
## Programming
The code for this project is written in C and uses the `` and `` libraries. In this code, time is calculated in minutes and seconds, and BCD values are generated for each digit. These BCD values are sent to the **BCD to 7-Segment Decoder (IC 7447)**.
```c
#include
#include
void main(void){
int i, j;
int seconds = 0;
int minutes = 0;
int s[4] = {0, 0, 0, 0};
DDRD = 0x0f;
DDRC = 0x0f;
while(1){
s[0] = minutes / 10;
s[1] = minutes % 10;
s[2] = seconds / 10;
s[3] = seconds % 10;
for (j = 0; j < 250; j++) {
for (i = 0; i < 4; i++) {
PORTD = ~(1 << i);
PORTC = s[i];
delay_ms(1);
PORTC = 0;
PORTD = 0;
}
}
seconds++;
if (seconds >= 60) {
seconds = 0;
minutes++;
if (minutes >= 60) {
minutes = 0;
}
}
}
}
```
---
## License
This project is licensed under the [MIT License](LICENSE).