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.
- Introduction
- Components Required
- How It Works
- Hardware Connections
- How to Run the Project
- Programming
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.
- 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
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.
- 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 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 |
- 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 |
- Hardware Connections: Connect the components as per the tables above.
- Compile the project code in a suitable programming environment (e.g., CodeVision or Atmel Studio).
- Program the generated HEX file onto the ATmega32 microcontroller.
- Power on the circuit and observe the time displayed on the 7-segment display.
The code for this project is written in C and uses the <mega32.h>
and <delay.h>
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).
#include <mega32.h>
#include <delay.h>
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;
}
}
}
}
This project is licensed under the MIT License.