Introduction: Make a Digital Clock From Scratch
In some point in the life of every electronics hobbyist the need to make a clock is borned, in my case it was about a month after I soldered my first part on a board, but back then I didn't have the right tools, parts and knowledge to do such a thing.
But after about 2 years I got all the things I didn't have back then and I was ready to make my first digital clock, and with all the LEDs I had left over from my 8x8x8 LED cube project I decided to make my own custom LED clock.
So join me and build your own custom LED digital clock powered by our favorite little micro-controller the Arduino.
Step 1: What Do We Need?
Here is what tools you will need to make this:
1) Soldering Iron.
2) Some solder wire.
3) Small needle nose plier
4) Small cuter
5) Wire striper
I made my clock with a stand alone arduino without the original board because I wanted to make a finished project.
Now here are the parts you will need to make the clock:
1) 130 LEDs.
2) 15 2N4401 transistors.
3) 20 1K resistors.
4) about 10 resistors for the current protection(more detail in step 2). I used 150Ohms.
5) DS1307 real time clock IC.
6) one coin cell battery holder.
7) 4 Tact switches.
8) Prefboard (you would like to get along one for the display about 8inch*3inch)
9) ATMega328 with arduino bootloader.
10) A programmer for programing the chip.
11) 7805 voltage regulator.
12) 16MHz crystal.
13) two 22pF caps.
14) 28 pin IC socket for the ATMega328.
15)10 uF cap.
16)0.1 uF cap.
17) 4017 counter
18) 32.768KHz crystal
Step 2: The Seven Segment Display
The clock is made of six seven segment displays which make up the display.
Each digit made of seven segments and every segment made of 3 LEDs in parallel.
So a simple calculation gives that there are 21 LEDs in each seven segment display.
And all six digits take 126 LEDs.
But as I said In the parts list you will need 130 LEDs and the other 4 LEDs are going to be used as dots that separate the hours, minutes and the seconds.
I made a common cathode display which means the all the negatives leads are connected together.
Now you will need to choose the right resistor for current limiting to 3 LEDs in parallel.
The calculation is simple and gos like this :
R=(Vcc-Vled)/(Iled*3)
R= the resistor value
Vcc = The voltage that is supplied
Vled = the forward voltage on the LED
Iled =the current the LED takes
You should always take a value a little bit bigger then the one in your calculation just to be on the safe side.
Step 3: So How It Works?
This kind of display calls for a large amount of pins to power it out so a special technique is needed.
I used multiplexing.
Multiplexing works by switching between the digits one by one very fast and by so creating a illusion that all of the displays are working in the same time.
This works by connecting each segment to the same one on a different digit and by so you will have only seven segments that are all the same for all the digits.
And you can choose what digit you want to power by connecting the negative leads of the display to ground and sending the data to the positive segment leads.
The scanning of the display is accomplished by the 4017 decade counter because I wanted to save some pins on the arduino, to control it you will need just 2 arduino pins.
The 4017 connects the grounds one by one and by so it scan the display.
Step 4: The Schematics
I did the best as I could to make a good schematic, I hope you will understand it.
(Note : That I forgot to add the resistor to the reset pin in the schematic so you will need to add a 1K resistor to the reset pin and Vcc)
To see the schematic better download it.
Some things I didn't added in there and they are the connection of the transistors to the display.
Now for the transistors that are connected to the 4017: There are just one unused pin in there and thats the collector and you need to connect it the ground of the seven segment display, each resistor is for one digit.
The transistors the are connected to the micro-controller has the emitter pin unused and you need to connect is to the segments via a current limiting resistor, each segment gets one transistor.
The 2 transistors that have a LED connected to them represent the 4 dots in the display you can see how to connect in the display picture.
Look at all the pictures in this step to know what goes where.
Step 5: The Program
Now it's time to program you ATmega chip.
But first install all 3 libraries that I have given like so.
Take your chip and put it in the arduino board and put the program I have added with this step.
The program is a bit messy but I did as best as I could to make it clean.
You ca set time and date in this clock so no time setting is needed when you program.
Time setting mode:
Press the "start/end setting mode" button, use the up and down buttons to set the time and the "next" button to move to the next part( it goes like this : hours, minutes,days, mouths ,years).
when you are done press the "start/end setting mode" button again.
Date:
Just press the "date/next" button.
Note:
There is no comments in the code, I will add them latter on.
Step 6: Your Done
Now you have your own working clock to tell you the time and date.
Now you can make or buy a nice box to close all the wires and make a cool finished project.
171 Comments
12 years ago on Introduction
i has a question do you mind if i rebuild this using vfd tubes?
Reply 12 years ago on Introduction
I don't mind at all, you can do anything you like.
Good luck with that mate!
Reply 12 years ago on Introduction
i only have one problem
can you put the code with comments up soon
then i can reprogram it easyer
Reply 12 years ago on Introduction
OK I will try to update the code by tomorrow.
Reply 12 years ago on Introduction
tank you
Reply 12 years ago on Introduction
It's up now, I am sure I have tons off spelling errors but I hope you wouldn't mind.
Good luck with your project
Reply 4 years ago
Hallo Sir
I build this whole circuit but can not find the Wprogram Libarary. Can you please send me the library or alternatife code for this wonderfull project
scheepers.frikkie AT gmail.com
Reply 9 years ago on Introduction
i finaly got it working
firsth time it did not work
and i gave up
it went into storage
but now it works
soon i will add a case
if i were to do it again
i would design a smaller power supply board
the board has:
0-10V lm317 (adjustable for the filaments)
0-100V ne555 (adjustable for the annodes)
5V 7805 (for arduino and all other chips)
ds1307 (for the time)
Reply 12 years ago on Introduction
it is great and understandable
how can i djust the code to put a dot in every display?
i know it is posible becaus you use a 8 bit number conviguration
but what arduino pin do i need?
Reply 12 years ago on Introduction
Well I used port D to control the segments but I only used 7 out of 8 pins.
This means that you can use that extra pin for the dots.
If every segment has a dot next to it you can simply add 0x80 to a number and it will light up the dot. Note that each dot needs to me connected to the common ground of each segment that way you need to use just 1 pin to control 6 dots(with the help of multiplexing).
Reply 12 years ago on Introduction
oke i will get tghat to work
but what pin on the arduino do i need?
Reply 12 years ago on Introduction
Digitla pin 7 ( PORTD)
Reply 12 years ago on Introduction
sorry i did not google it yet
and now i found it
tank you XD
7 years ago
Hi, i have finished making the circuit and i uploaded the program to my atmega328 chip.
But there's a problem. When i connect a 9V battery to it, only the 4 dots lit. I am confused maybe it's because of the wiring but i definitely did what it is written in there and in the diagram. Also maybe because of the resistors i used? By the way i used yellow LEDs and i used 150ohms resistor for current limitting. Can you help please? Or anyone? Thanks.
Reply 7 years ago
Also i am wondering. You use 150ohms for current limitting for 3 blue LEDs in parallel. But when i compute it with what formula you gave i only got 20ohms. (Vcc-Vled)/(Iled*3)
Reply 4 years ago
Hallo. Did you ever get this to work? I got everything and spend days building the sircuit but now i HAVE A LIBARARY ISSUE. Program.h is not available any more
can you help please
4 years ago
exit status 1
WProgram.h: No such file or directory ?
5 years ago
Hi, I want to use the 2.3 inch 7 segment display. Can I use the same wiring diagram and ic's ?
Reply 4 years ago
Hey... Did you make this? Please reply
Reply 4 years ago
Not yet, I think in 4 to 5 months I will make it.
Pd: I did not get any reply about if I could use the same wiring diagram and ic's