Simple Digital Clock

Simple Digital Clock
Simple Digital ClockSimple LED Clock 7-segment LED clock
4.33333 5 3 Product

This is a simple time-of-day digital clock, a good starting point for learning the basics on microcontrollers. It uses the 18-pin PIC16F84A, a seven-segment LED clock display and three input switches. The circuit is based on Dan Matthews’s project, initially described on Microchip’s AN-590. Dan Matthews’s project uses a PIC16C54, so the code has been modified to be used with the more popular PIC16F84A. We almost preserve the same hardware and we have designed an appropriate printed circuit board for making construction simple. 

The electronic circuit

The individual segments of the display are connected together, A-A-A-A, B-B-B-B, etc. The PORTB pins activate the LED segments. The connections are RB1-A, RB2-B, RB3-C...RB7-G. The center clock colon is connected on RB-0. 

The electronic circuit of the simple digital clock
The electronic circuit of the simple digital clock

The common cathode for each display segment is turned on from four I/O lines of PORTA. The connections are RA0/Digit1, RA1-Digit2, RA2-Digit3, RA3/Digit4 (the display segments are numbered from the left, or most significant digit).

The switches are also connected to PORTB I/O pins. To read the keys, since we utilize every pin for output, we switch some of the outputs to inputs briefly. PORTB pins RB1, RB2, and RB3 are pulled low with 10 KΩ resistors. This value is high enough to not draw current away from the LEDs when they are being driven on. Inputs are detected by pulling the pins high with a switch to VDD through 820 Ω resistors. This value is low enough to pull the pin high quickly when the outputs have been turned off, and to create a 90% of VDD high input.


The simple digital clock is a 12-hour clock, meaning that there is no distinction between a.m. and p.m. When no buttons are pressed, the circuit will display the current time, starting at 12:00 on reset. Pressing SW1 will cause seconds to be displayed. The time is set by pressing SW2 to advance minutes, and SW3 to advance hours. Since each of the segments are tied together across all displays, only one display should be turned on at a time, or all displays turned on would display duplicate data. The displays are turned on right to left, with each display's value being output in its turn. This is done fast enough so that there is no perceived flicker. The switches are read between display cycles.


The circuit is very small, and therefore can be used as a clock on a bedside table or as an office clock without using up too much space. The clock can be powered from 4 to 5.5V and consumes about 40 mA during normal operation (about 0.2W).

Due to its relative high consumption, powering from batteries isn’t a good idea, and you’ll definitely need a small power supply unit. However, batteries can be used as backup energy source in case of main power source fail. Using batteries for backup, you will avoid any sudden reset when main power fails.

For connecting batteries as backup power source, use the reference below (see figure 1). 

Backup batteries
Figure 1. How to connect backup batteries

Download section

Printed Circuit Board Artwork for the simple digital clock
Components palcement on the PCB - composite drawing
Download the microcontroller's code (hex file)


List of the comments:
No comments have been posted yet.
You must be registered in order to post a comment