Digital Clock With 7-segment LED Display
by jandb86 in Circuits > Arduino
3973 Views, 16 Favorites, 0 Comments
Digital Clock With 7-segment LED Display
The most common 7-segment application is making the digital clock.
There are various commercial 7-segment parts available but their size is not big enough to make a wall mount type of digital clock.
That’s why I’m using the small square shape of LEDs for making big size and customized 7-segment-based digital clock.
Every day in the morning, frequently I need to check the clock to catch the company commuter bus going to my office. (About 45Km from my home)
Therefore, the digital clock is quite a useful device among the all DIY results from my all previous projects.
This is the first useful digital clock that supports the reliable and sustained operation.
Maybe several variants or possible upgrades can be possible later starting with this prototype.
Let’s look at the details of this digital clock.
Schematics
Although the schematics seem a little bit complex (frankly speaking it’s truly complicated while wiring and soldering this circuit), overall circuitry can be divided into four parts like below.
- DS3231 Real Time Clock (It’s the main component that keeps exact time data)
- Arduino Uno board for displaying the number on the LED 7-segment display
- LED-based 7-segment display showing time
- LM2596-based switching power supply module
As the DS3231 and Arduino Uno is quite common system boards, they will not necessary further explanation.
For this project, the Arduino Uno is used as it can supply significant current (more than 100mA) to peripherals.
Otherwise, the main controller (Arduino board) will be stressed so much and can’t support sustained operation in a 7x24 manner.
For the LED 7-segment display, a total of 7 transistors (BD140 PNP) are used for controlling 2 hours digit LEDs, 1 colon (Separator between hours and minutes with 2 LEDs), 2 minutes LEDs, and 2 seconds digit LEDs.
For every single 7-segment, a common anode type LED configuration is used to show a single numeric digit.
Utilizing a PNP transistor and common anode 7-segment display is a typical LED display module driving method.
I’ll explain how the time string (HH:MM:SS) is displayed on the 6 digits of 7-segment displays while explaining the sketch program at a later step.
As long and sustained operation is required as 7x24 by this digital clock, less heat producing and efficient LM2596-based switching power supply circuit is utilized instead of LM7805 voltage regulator circuit.
Usually, serial voltage regulator circuits (LM7805) produce quite much heat when the input voltage is quite high such as 15~18V.
Shown LM2596 circuit can support 15~18V input and produce 1.2 ~ 17V adjustable up to 3A power output.
Although a commercial LM2596 step-down voltage regulator breakout board is available, I tried to make a more reliable and sustainable power supply by making my own.
Therefore, more high-quality electrolytic capacitors and a bigger heat sink are used in my power supply circuit.
Parts
For making this digital clock, selecting a good equipment enclosure and a well-fitted size universal PCB was very important.
To use it frequently and conveniently in everyday life, good looking, dust protecting, and well-made equipment enclosure is highly desirable.
Therefore, the following parts are searched and purchased from the Internet shop.
- Plastic enclosure: Multicomp MC001108, 171mm(W)x121mm(D)x55mm(H)
- Universal PCB: 150mm(W) x 100mm(D), hole size 0.9mm and 2.54mm pitch (Between holes)
I’m always using acrylic boards for making equipment chassis (Usually air-tight enclosure is not possible with acrylic boards) to mount all circuit boards.
But making dust-protecting equipment box or enclosure with acrylic boards are not easy.
Therefore, I used commercially available and ready-made plastic enclosures.
Also finding the correct size of universal PCB board tightly fitting to the selected plastic enclosure is a little bit difficult.
Although I need to cut four corners of the universal PCB, luckily found PCB fitted exactly inside of the plastic enclosure.
For making a numeric pattern with square type of LEDs, an IC pin-header socket is used for plugging the lead of individual LED into it.
When you make an LED display PCB board like this, you can plug in other colors of LEDs later.
For making 6 digits of a 7-segment LED display board, the following parts are necessary.
- Yellow color square shape LED 56EA for HH:MM data displaying
- Red color LEDs 14EA for displaying seconds
- IC pin header sockets
- Male pin header for connecting transistor control and 7 data lines (a, b, c, d, e, f, g part of 7-segment pins)
- BD140 PNP transistors
- 1.5K resistors 6EA for driving BD140 transistors
- 150ohm resistors 6EA and 330ohm resistor 2EA (LED current limiting resistors)
Although I used a relatively heavy-duty transistor (BD14), you can use small signal general purpose PNP transistors such as 2N3906 or 2N4403.
Somehow I have numerous BD140s in my inventory and that’s why I used that transistor model.
As big size of 7-segment display parts (HH:MM) using two LEDs for 7 data segments (a, b, c, d, e, f, g), a small value (150ohm) of current limiting resistor is used for turn on LEDs more brightly.
But only 2 LEDs are connected for the colon (Separator between hours and minutes LEDs) part 330ohm current limiting resistor is used.
From the start, I considered putting a small size 5V cooling FAN inside the enclosure.
But controlling FAN with the sketch program and wiring the FAN control board becomes a little bit difficult.
Therefore, I discarded cooling FAN circuit parts from this prototype. (Maybe a later version will have it!)
For the LM2596 switch power supply circuit, the following parts are used.
- LM2596 adjustable switch power supply IC
- IN5822 SCHOTTKY BARRIER diode
- 33uH inductor (more than 3A)
- 220uF x 2 electrolytic capacitor, 0.1uF x 2 ceramic capacitor, 0.003uF film capacitor
- 510ohm, 680ohm resistors
- Power socket (male and female)
I’ll show details of the LM2596 switch power supply circuit in the later step.
Except explained parts mentioned above, the following common system boards are used.
- Arduino Uno compatible board
- DS3231 real-time clock breakout board
For connecting system boards and LED display/power supply PCB, DuPont wires are used.
Let’s look at each major PCB from the next step.
Wiring and Soldering 7-segment Display
When you complete wiring and soldering this 7-segment display board, more than 80% of the digital clock is made.
Because this display board is the most complex part of making this digital clock.
As you can see in the schematics and wiring picture above, careful wiring and soldering are required.
To support more convenient wiring and soldering 7 segment data lines (a ~ g LED connection), a tin wire-based data bus is made as you can see in the wiring picture above.
For simplifying the wiring schematics, I depicted only 1 LED for hours and minutes 7-segment display. (But this part consists of 2 LEDs)
As each 7-segment is controlled by one PNP transistor, 7 control lines (PIN9 ~ PIN13, A1, and A3) are connected with the Arduino Uno.
As you can see in the last picture, the 7-segment display board is connected to an Arduino Uno board with DuPont wires.
The power supply lines (Vcc and GND) are not depicted in the wiring diagram above, Vcc (5V) power line from Arduino is connected to all emitter leads of the BD140 PNP transistor.
Making LM2596 Switch Power Supply Board
As I mentioned in the step above, a commercial and fixed 5V LM2596 step-down switch power supply break-out module is available.
But I tried to make a more robust and sturdy power supply module by using high-quality capacitors and other components of this circuit.
As shown in the picture above, I need to connect this digital clock to an 18V/1A wall power supply adaptor or 15V switching power supply unit.
The technical specification and functionality of this custom circuit are the same as commercially available break-out board.
Assembling of PCBs Inside Enclosure
Originally including cooling FAN is considered to cool down circuit boards housed inside an enclosure.
Therefore, venting holes are made on the opposite side of the plastic enclosure.
But as you can see in the last picture above, wiring become so much complicated and making the FAN control program is a little bit tricky.
Therefore, finally, cooling FAN is excluded from the last version of the digital clock circuit.
As you can see in the last picture, the plastic enclosure bottom is very crowded with many PCBs.
Above this crowded enclosure bottom, the 7-segment display PCB board should be mounted.
Sketch Program Making
To understand the operation of this digital clock, the most difficult part is showing the number string on the 6 digits of the 7-segment display.
Therefore, I recommend reading the following Instructable for showing a number on the common anode 7-segment LED display.
https://www.instructables.com/File-Server-With-Current-Meter/
Getting a timestamp from DS3231 is a simple system call as follows.
- hours = now.hour()
- minutes = now.minute();
- seconds = now.second();
When time data is stored to integer values such as hours, minutes, and seconds, each digit for HH:MM:SS is calculated like below.
- digit1 = (hours/10) % 10; // When assume hours is 12, result become 1
- digit2 = hours % 10; // digit2 becomes 2
- digit3 = (minutes/10) % 10; // When assume hours is 34, result become 3
- digit4 = minutes % 10; // digit4 becomes 4
- digit5 = (seconds/10) % 10; // When assume hours is 56, result become 5
- digit6 = seconds % 10; // digit6 becomes 6
As all digits of the time data (HH:MM:SS) are calculated, then displaying each digit to the intended position like below. (Let's assume present time string is 12:34 56, 12 hours, 34 minutes, and 56 seconds)
- Turn on the transistor #1 (Leftmost position such as Hx : xx xx) and show digit1 (such as 1x : xx xx)
- Turn on the transistor #2 (2nd from Leftmost position such as xH : xx xx) and show digit2 (such as x2 : xx xx)
- Turn on the transistor #3 (3rd from Leftmost position such as xx : Mx xx) and show digit3 (such as xx : 3x xx)
- Turn on the transistor #4 (4th from Leftmost position such as xx : xM xx) and show digit4 (such as xx : x4 xx)
- Turn on the transistor #5 (5th from Leftmost position such as xx : xx Sx) and show digit5 (such as xx : xx 5x)
- Turn on the transistor #6 (rightmost position such as xx : xx xS) and show digit6 (such as xx : xx x6)
Each digit is displayed on the designated position of the 7-segment display and then waits a very short time (delay(1), 1/1000 second).
And when repeating the above display and waiting for actions 50 times, numbers are shown steadily on the 6 digits of the 7-segment display. (It’s a kind of visual illusion like showing a movie with many frames of the photo included in a film roll).
After showing time digits 50 times, colon LEDs are toggling (ON to OFF and OFF to ON).
Therefore, the colon LEDs are blinking by turning on and OFF per each 300ms (1ms x 6 digits display x 50 times).
That’s how this digital clock is operating.
Downloads
Operation and Conclusion
As 72 LEDs (56 yellow and 16 red) are used, I guessed more than 100mA (assuming individual LED is consuming about 10mA, roughly 700mA of current seems required) is flowing to this clock circuit.
But as you can see in the video in the following link, the current flowing to this clock changes from 40mA to 100mA).
https://drive.google.com/file/d/1CeBQwiZC-ydp7stHvsaGcAGftG70bV5w/view?usp=sharing
Although many LEDs are used, only a single digit of the 7-segment display is turned on according to the sketch program explained in the above step.
When assuming all 14 LEDs are turned on (displaying number 8) by the rightmost digit, about 90mA is required.
Each individual LED of the rightmost 7-segment digit display seems to consume less than 10mA.
The 40mA of minimum current level seems required power for turning on the second part of the digit.
As this digit consists of 7 LEDs, the required current level is very low.
Anyway, the digital clock seems correctly operating and very useful in everyday life.
The only problem is this circuit lacks a forced cooling mechanism with FAN.
Maybe a later version will have cooling FAN and other advanced features.
Thank you for reading this story.