Photography and Projects

PIC Time & Date Clock

Stacks Image 195
This is a digital clock that tells the time and date at the same time on LED displays. The clock is based around a 16F886 Microchip Microcontroller and the program is written in 'C'. I chose this microcontroller because the application needed a 28 pin microcontroller and I already had one available. The program can be adapted to most pin compatible PIC microcontrollers.

The features I wanted from this clock follow the original project however I wanted to simplify the circuit using a PIC with more I/O than I was able to use at the time.

0 ratings

Project Description.

Features include:

  • Use 7 segment LED displays for a large bright clock display.
  • Display Time and Date at the same time.
  • Buttons to set Time and Date
  • Keep track of leap years
  • Fit in a small box

A feature of the program is time correction. You can set the value to lose or gain time to keep the clock accurate. In this new version I could also add seconds to the time as I had more I/O available. It is optional as omitting the displays, transistors and resistors will not affect the running of the clock.
Two buttons are used to set the time and date. You press the first button to go into set mode where all digits apart from the ones currently being set are shown as '—'. First the hours are set. Use the other button to increment the hours. When at the desired setting press the first button again to move the the minutes. You will notice now the hours are displayed as '—' and the minutes are displayed. In the same way you can use the second button to increment the minutes. If you make a mistake and go past the setting you want you can continue to increment as the digits will roll over from 59 to 0. Next is Years followed by Month and finally Day. It is done in this order to make sure you cannot set an invalid date. For instance, if the year is not a leap year and the month you set is February, when you increment the day past 28 it will go back to 1. You cannot set the day to 29. However, if it is a leap year you will be able to.


The circuit diagram was created in Eagle CAD so a PCB could be created from the circuit. The Clock and the Display circuits are separate and are described below:
Stacks Image 48
At the centre of the circuit the is PIC microcontroller which is responsible for keeping and displaying time. The time is displayed on 7 segment LED displays using the outputs on port B. As we have 12 digits in our clock we have to multiplex the digits. This means sharing port B for all 12 digits. 12 more outputs are used to switch on each digit using a transistor one at a time. So we set the first digit on port B then turn on the transistor for digit 1. Then we turn off digit 1, set port B for digit 2 and then turn on digit 2. This continues for each digit until we get back to the first digit again. If we do this fast enough the human eye will not see the digits flicker.
We have 2 inputs defined for the buttons and a crystal is used to provide the timing for the microcontroller. Finally a 5v regulator is provided with some capacitors to decouple the supply rails.
Stacks Image 55
The display circuit consists of 3 dual digit displays. They are common cathode displays meaning the segments are connected together on the cathode side.
All digits are connected to the same 8 lines which will connect to port B on the clock circuit. Each of the digits cathodes are separately connected to each transistor on the clock circuit.
Two of these circuits are required for the full Time and Date clock, one to display the time and one to display the date.

Printed Circuit Board.

For the complete clock you need one Clock PCB and two Display PCB's. The images are below. The top layer is shown in red and the bottom layer is blue. The holes and connectors are aligned on all boards.
The Clock PCB:
Stacks Image 74
The Display PCB:
Stacks Image 78


Stacks Image 168
The constructed clock PCB is shown on the right. Start with the resistors then move on to the IC socket, capacitors, crystal and transistors.
The display resistors are mounted vertically between the PCB's. You can just about make them out on the top left of the photo. Wires are used to connect the switches and external power to the PCB.
The 5 pin connector on the bottom left is for programming the PIC when it is plugged into the socket. It is at right angles so it can be accessed when the display is connected. I use the MikroE In-circuit programmer.
The crystal I used was too tall to mount vertically so I bent the leads at right angles. However, due to the capacitor placement on the PCB I had to mount the crystal further away than I would like.

Stacks Image 173
The photo on the left shows the two assembled display boards. Assemble each board with care making sure the display is square to the edges of the PCB and to each other. I found soldering one pin at opposite corners first to help locate and position the display. Only when I was happy the display was square did I solder the remaining pins.
With the two assembled boards side by side I linked them together with leads cut from the resistors soldered on the clock PCB. Only the 8 pins on the middle left need to be linked.
After assembling the PCB's they are joined together. The 8 connections on the top left are made with the resistors. The other 12 connections (top right and bottom right) are made using single strand wire. If the wire is rigid and the connections are all the same length the PCB's stay apart without the need to use screws.

Parts List.

Parts List Under Construction


Program under construction



Project Summary.

After completing a project I always find things I would like to improve. This could be to make it easier to build or to correct errors. It can also be something to improve the project. These are some changes I would like to make if I make a future update:

  • Include the display resistors on the clock PCB so the PCB's can be linked with wire instead.
  • Move the crystal capacitors so a large crystal can be laid flat.
  • Use a smaller crystal.
  • Update software to keep track of the day of week so summer time can be set and unset

These will be saved for a later date.

I hope you enjoyed this project and have found it useful. Use the contact section if you want to ask questions or let me know of any issues.


Original Project Details (PDF):

Original Project Files (ZIP):

Project Details

PIC Clock

All content I publish is my own work and I own the copyright.
If you enjoy the content provided please consider showing your appreciation by donating using the link below.

RapidWeaver Icon

Made in England