6 Digit LED Clock

6 Digit LED Clock

6 Digit LED Clock

I recently found six 2.3″ red 7 segment displays in my collection which I purchased from Rapid Electronics when they were clearing out non-RoHS stock. Since I have no clock at my work bench I decided to construct one from some prototyping pad board, a Microchip PIC18F26K20 microcontroller and a Dallas DS32KHZ temperature compensated 32.768kHz crystal.

The displays I used are SA23-12SRWA, which don’t appear to be available from Rapid any more, the closest is SA23-12EWA, however, Farnell and the other usual distributors sell them.

SA23-12SRWA 2.3" 7 Segment Display

SA23-12SRWA 2.3″ 7 Segment Display

I wanted this to be a fairly quick project to complete, so the schematic is fairly simplistic. The schematic diagram of the clock is shown below:

Full 6 Digit Clock Schematic

Full 6 Digit Clock Schematic

The 7 segment displays are common anode displays, with segments consisting of four red LEDs in series and the decimal places consisting of two red LEDs in series. To reduce the number of GPIO used to drive the display, various methods can be used – such as multiplexing, shift registers or dedicated display drivers. I’ve chosen to use plain display multiplexing, requiring one GPIO for each digit common anode, and one GPIO for each segment – with the colon separators, that gives 7 common anodes, and 8 cathodes with the decimal places and colons commoned together. There are many methods to reduce the number of GPIOs needed further than this, but the chosen microcontroller does not have a shortage of GPIO for this application.

The forward voltage of the segments is slightly high – the datasheet specifies between 7.4V and 10V. For this reason, the anode drivers for the displays have to perform both voltage translation in addition to sourcing enough current for the displays.

Common Anode Drivers

Common Anode Drivers

A BC327 PNP transistor is used to source the 12V supply to the digit common anode. The transistor used here must be rated for the full current of each digit with all segments lit. The BC327 is rated for a maximum collector current of 800mA, which is more than adequate for these displays, even when driving them at high peak forward currents. With a minimum current gain of greater than 100, the 2kΩ limits the maximum base current to prevent damage to the transistor whilst allowing around 500mA collector current to flow.

The voltage translation is provided by a ULN2003A darlington transistor array. This is effectively a package of 7 open collector darlington transistors which is used in this circuit to turn the BC327 on by pulling the base to 0V through the 2kΩ resistor. The 10kΩ resistor acts as a pull up resistor to hold the transistor off when the open collector transistor is off.


8 Channel Cathode Drivers

8 Channel Cathode Drivers

The cathode drivers simply use a ULN2803 8 channel darlington transistor array to drive the individual segments on the displays. The open collector configuration rather than a logic 1/0 is important here in order to prevent the digits staying dimly lit when turned off. If 3.3V logic drivers were used, the logic high of ~3.3V could still provide a high enough potential difference between the anode drive to cause the LEDs to remain lit.

You’ll notice the cathode current limiting resistors here – these have been selected to drive the display at higher than the 20mA rated current of the displays. When the displays are multiplexed, the maximum duty cycle is limited to 1÷(multiplex cycles), in this case, 1/6 or around 16%. Provided that maximum power dissipation in the LEDs do not exceed the datasheet specified value, it is safe to drive the LEDs at higher current to recover the original brightness of the LEDs.

The clock is driven by a Microchip PIC18F26K20 microcontroller. This is a 28 pin device and was somewhat arbitrarily selected based on the first 28 pin microcontroller I came across in my collection. Very little processing power is required for this clock, so selection was merely based on having at least two hardware timers which were configurable enough for multiplexing the displays and keeping time. Although I plan to interface this clock with my GPS Disciplined Oscillator, this build has a local crystal so that it can be used as a standalone clock and also so any readers of this blog can build their own.

I chose to use a Dallas DS32KHZ Temperature Compensated Crystal Oscillator, purely because I quite like the devices in this range – both the integrated RTC modules and the plain TCXOs. It also means you don’t have to worry too much about tweaking the load capacitors on your 32.768kHz crystal, or adding in code to correct for oscillator drift.



The TCXO just needs power and it’ll output a 32.768kHz square wave which in this circuit is fed directly into the Timer 1 clock input. The crystal oscillator regularly checks the temperature and adjusts the output frequency to maintain a relatively accurate 32.768kHz output.

The microcontroller code can be easily adapted for a standard 32.768kHz crystal if required.

Power for the microcontroller is provided through a 3.3V regulator from the 12V supply rail.

3.3V Logic Supply

3.3V Logic Supply

When the circuit was being designed, I wasn’t sure if I’d add any status LEDs or anything else to the circuit, so I estimated with the microcontroller running at 16MIPS, TCXO and some additional margin, the 3.3V regulator should be capable of providing 60mA. Given the LP2950-33 used here is in a TO92 package, the ~500mW dissipation at 60mA is a little high for comfort. Three 330Ω resistors in parallel are used here to dissipate up to ~400mW of the power when the regulator is fully loaded at 60mA, whilst ensuring the supply voltage to the LP2950-33 is high enough to maintain regulation. A single larger ~110Ω resistor could be used, however I had none available.

The schematic also shows an RS485 transceiver set up for reception only – this is to interface with my GPSDO, so not needed in typical applications.

Assembled PCB - Front Side

Assembled Clock – Front Side with Middle Digits Removed

Assembled clock on prototyping board

Assembled clock on prototyping board – 32kHz TXCO on transition board

Current setting resistors on resolderable standoffs

Current setting resistors on re-solderable standoffs

3.3V Regulator and associated circuitry

3.3V Regulator and associated circuitry


Clock with acrylic front panel

Clock with acrylic front panel

The code to drive the clock is attached below, designed for Microchip XC8 compiler. This runs the microcontroller at the full 16MIPS, multiplexes the displays at 250Hz and uses the three momentary buttons to set the time.

6 Digit Clock – main.c

I’ll add a bit of documentation to go with the code shortly.

Please feel free to use the schematic and code to build your own clocks for your lab. Don’t forget to post a comment below with any pictures or comments!


28 thoughts on “6 Digit LED Clock

  1. Hello ,
    I find this project very useful, I love electronics and I wanna be like u.
    wish me the best.

    Thanks Ahmed.

  2. I like the finishing touch with the smoked acrylic case.

    I did a similar build, but with an arduino and much smaller 7-segments (it didn’t warrant any transistors and a separate supply line). I multiplexed the digits in the same way.

    I could’ve driven it with more current–I wish I had known this was the case, but I didn’t know that you could provide a higher peak current when multiplexing the LEDs. I didn’t have a data sheet for them so I didn’t want to burn it out and went the safe route.

    Thanks for going into all the detail, it really explained a lot of stuff about circuit design that I haven’t found anywhere else.

  3. Hi,

    I wonder which program you use to program the PIC..
    send me a link if you won’t mind me asking that..


  4. HI,
    Thanks for the innovation and may God bless you as you are contributing to the growth of the young engineers.
    I saw something like an IC on the prototyping board: what is it call, must we solder it at the back of the prototyping board and what is it for.

  5. Hello Steve, just been looking at your clock project and was wondering if your schematic is correct around the Darlington driver ICs as you show the Common connection (pins 9 & 10, ULN2003 & ULN2803 respectively) connected to ground as opposed to supply.



    • Hi Lee,

      Good catch, looks like I messed up – the common emitter pin is hidden in the schematic and I have mistaken that for the COM pin. I’ll update the schematic in due course! Thanks for the message.


      • Thanks for the excellent website and projects. I have been looking for something like this clock project for a while now. I am planning to build. So from the comments above the Common on the Darlington arrays would be connected to 3.3V instead of ground?

    • @ihab Riad : may be you can plus a negacy mark(~) in every char segment array…. CMIIW from newbie

  6. Hi Steven,

    Just got all the parts in for the digital clock. I do still have a question about the Darlington transistor arrays. Back on 10/1/15 Lee brought up a point about the COM (pin 10 on the ULN2803 and pin 9 on the ULN2003a) tied to GND. Does that pin need to go to +12v or GND? It seems from the data sheets that 9, 8 respectively are the common emmitters that should be GND. Please advise thanks. BTW great site and very informative videos. I am not an EE just a hobbyist.

    • Rob,

      I am also not an EE, so take what I say with a grain of salt. Pin 10 on the ULN2803 and pin 9 on the ULN2003a are only needed for inductive loads per the data sheet (i.e., not needed for this application). Pin 9 on the ULN2803 and pin 8 on the ULN2003a should go to ground. The schematic is correct except that COM should have been labeled E (emitter).

  7. How big is that pad-board pcb?, And where did you source it? I’m struggling a bit to find big ones..

  8. Steve,
    The build is complete. The clock is running like a champ. Going to post some pictures. Look for the link on this blog. Also I am going to play around with the code a bit to fully understand the multiplexing and possibly look into an AM / PM version (I know we US folks like AM and PM). This was my first PIC project. Also I am going to look for some more PIC related stuff to fully understand microcontroller devices. Many thanks to Steve for the excellent videos and sharing his knowledge of electrical engineering.

      • Hi Dan,

        Thanks for the comment. I was just waiting to get my website a little further along but since you forced the issue here are some pics http://www.thebrunonet.com. Oh and by the way I really did build the project and I hope you will be a little less judgmental in the future. As I said earlier I am hobbyist and do not have 100% of my time focused on this project or forum.

Leave a comment

Your email address will not be published. Required fields are marked *