Summary
This project describes building a 6-digit 7-segment clock using an AVR microcontroller (ATMEGA128). It involves assembling six common anode 7-segment displays, PNP transistor drivers, resistors, and an NTC resistor for temperature sensing. The ATMEGA128 microcontroller drives the display using interrupts and timers to keep track of time, with source code and hex files provided. The project also includes push buttons to adjust hours and minutes and can be extended to a calendar function. Video demonstrations show the working clock.Parts used in the 6 digits 7 segments clock with AVR microcontroller:
- 6x 7 Segments Common Anode
- 6x PNP transistors (2N3906)
- 6x 1K 1/4W resistors
- 1x ATMEGA128 microcontroller module
- 1x NTC resistor 10K
- 1x 10K resistor 1/4W
- 2x Push buttons for adjusting hour and minute
- 1x USB ASP programmer
- Atmel Studio (software)
This project is explaining how to create yourself a 6 digits 7 segments clock with AVR microcontroller
Step 1: Prepare the Parts for This Project
We need to prepare a parts for this project,
6x 7 Segments Common Anode
6x PNP transistors for driver, I used 2N3906
6x 1K 1/WW resistors
1x Module ATMEGA128
1x NTC resistor 10K
1x 10K resistor 1/4W
2x Push button for adjusting the hour and minute
1x USB ASP
1x Atmel studio
Step 2: The Segment Code
I have written the segment code for this project,
Please have a look on the picture in this step….
That’s how I drive each seven segment with PNP transistor, it’s cheap but more than enough for driving 8 segments
Step 3: The Firmware and MCU Selection
You’re going to need at least 15 I/O from your MCU for this project,
In my case I used ATMEGA128, but you can use ATTiny2313,ATMEGA8,ATMEGA16 and others family of AVR 8-bits
I’m using interrupt and timer to increase second, you can upgrade to a calendar as well if you one, quite simple and straight forward.
Hex file is included if you want to use ATMEGA128
Here’s the setup for my timer and ISR :
ISR(TIMER1_COMPA_vect)
{ seconds++;
if(seconds == 60) {
seconds = 0;
minutes++; }
if(minutes == 60)
{ minutes = 0; hours++; }
if(hours > 23) hours = 0; }
Step 4: The Demo in Video
Source: 2cm Height 7 Segments 6 Digits AVR Clock With 4 Digits Thermometer