|
1 | | -# Timer-4digit-7segment |
2 | | -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. |
| 1 | +# Display Time on a 4-Digit 7-Segment Display Using ATmega32 and BCD to 7-Segment Decoder (IC 7447) |
| 2 | + |
| 3 | +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. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Table of Contents |
| 8 | +- [Introduction](#introduction) |
| 9 | +- [Components Required](#components-required) |
| 10 | +- [How It Works](#how-it-works) |
| 11 | +- [Hardware Connections](#hardware-connections) |
| 12 | +- [How to Run the Project](#how-to-run-the-project) |
| 13 | +- [Programming](#programming) |
| 14 | + |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +## Introduction |
| 19 | + |
| 20 | +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. |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## Components Required |
| 25 | + |
| 26 | +- **ATmega32** microcontroller |
| 27 | +- 4-digit 7-segment display (Common Cathode) |
| 28 | +- BCD to 7-Segment Decoder (IC 7447) |
| 29 | +- NPN transistors (e.g., 2N2222 or BC547) (4 pieces) |
| 30 | +- 5V power supply |
| 31 | + |
| 32 | +--- |
| 33 | + |
| 34 | +## How It Works |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +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. |
| 39 | + |
| 40 | +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. |
| 41 | + |
| 42 | +The time increments every second, and after reaching 60 seconds, the minutes increase. If the minutes reach 60, they reset to zero. |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +## Hardware Connections |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | +### Port C (PORTC): |
| 52 | +- Port C is used to send BCD values to the **BCD to 7-Segment Decoder (IC 7447)**. |
| 53 | +- Each BCD value corresponds to a digit (0-9). |
| 54 | + |
| 55 | +| 7448 Pin | Microcontroller Port | |
| 56 | +|---------|----------------------| |
| 57 | +| A | PC0 | |
| 58 | +| B | PC1 | |
| 59 | +| C | PC2 | |
| 60 | +| D | PC3 | |
| 61 | + |
| 62 | +### Port D (PORTD): |
| 63 | +- Port D is used to control the common cathodes of each digit. |
| 64 | +- Each pin of Port D is connected to the base of an NPN transistor. |
| 65 | +- The collector of the transistor is connected to the common cathode of a digit on the 7-segment display. |
| 66 | +- The emitter of the transistor is connected to ground (GND). |
| 67 | + |
| 68 | +| input Not Gates | Microcontroller Port | |
| 69 | +|-------------------|----------------------| |
| 70 | +| Gate 1 | PD0 | |
| 71 | +| Gate 2 | PD1 | |
| 72 | +| Gate 3 | PD2 | |
| 73 | +| Gate 4 | PD3 | |
| 74 | + |
| 75 | + |
| 76 | +| 7-Segment Cathode | output Not Gates | |
| 77 | +|-------------------|----------------------| |
| 78 | +| Digit 1 Cathode | Gate 1 | |
| 79 | +| Digit 2 Cathode | Gate 2 | |
| 80 | +| Digit 3 Cathode | Gate 3 | |
| 81 | +| Digit 4 Cathode | Gate 4 | |
| 82 | + |
| 83 | +### BCD to 7-Segment Decoder (IC 7447): |
| 84 | +- The BCD inputs (A, B, C, D) are connected to Port C of the microcontroller. |
| 85 | +- The 7-segment outputs (a, b, c, d, e, f, g) are connected to the corresponding segments of the 7-segment display. |
| 86 | + |
| 87 | +| IC 7447 Pin | 7-Segment Pin | |
| 88 | +|-------------|---------------| |
| 89 | +| QA | A | |
| 90 | +| QB | B | |
| 91 | +| QC | C | |
| 92 | +| QD | D | |
| 93 | +| QE | E | |
| 94 | +| QF | F | |
| 95 | +| QG | G | |
| 96 | + |
| 97 | + |
| 98 | +| IC 7447 Pin | Connected to | |
| 99 | +|-------------|---------------| |
| 100 | +| LT | VCC | |
| 101 | +| RBI | VCC | |
| 102 | +| BI/RBO | VCC | |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +## How to Run the Project |
| 109 | + |
| 110 | +1. **Hardware Connections**: Connect the components as per the tables above. |
| 111 | +2. Compile the project code in a suitable programming environment (e.g., CodeVision or Atmel Studio). |
| 112 | +3. Program the generated HEX file onto the ATmega32 microcontroller. |
| 113 | +4. Power on the circuit and observe the time displayed on the 7-segment display. |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | +--- |
| 119 | + |
| 120 | +## Programming |
| 121 | + |
| 122 | +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)**. |
| 123 | + |
| 124 | +```c |
| 125 | +#include <mega32.h> |
| 126 | +#include <delay.h> |
| 127 | + |
| 128 | +void main(void){ |
| 129 | + int i, j; |
| 130 | + int seconds = 0; |
| 131 | + int minutes = 0; |
| 132 | + int s[4] = {0, 0, 0, 0}; |
| 133 | + DDRD = 0x0f; |
| 134 | + DDRC = 0x0f; |
| 135 | + |
| 136 | + while(1){ |
| 137 | + s[0] = minutes / 10; |
| 138 | + s[1] = minutes % 10; |
| 139 | + s[2] = seconds / 10; |
| 140 | + s[3] = seconds % 10; |
| 141 | + |
| 142 | + for (j = 0; j < 250; j++) { |
| 143 | + for (i = 0; i < 4; i++) { |
| 144 | + PORTD = ~(1 << i); |
| 145 | + PORTC = s[i]; |
| 146 | + delay_ms(1); |
| 147 | + PORTC = 0; |
| 148 | + PORTD = 0; |
| 149 | + } |
| 150 | + } |
| 151 | + |
| 152 | + seconds++; |
| 153 | + if (seconds >= 60) { |
| 154 | + seconds = 0; |
| 155 | + minutes++; |
| 156 | + if (minutes >= 60) { |
| 157 | + minutes = 0; |
| 158 | + } |
| 159 | + } |
| 160 | + } |
| 161 | +} |
| 162 | +``` |
| 163 | +
|
| 164 | +--- |
| 165 | +
|
| 166 | +## License |
| 167 | +
|
| 168 | +This project is licensed under the [MIT License](LICENSE). |
| 169 | +
|
0 commit comments