the time is displayed in 24 hour mode so:
To show the time 6 digits are needed as follows:
Hours
|
MSD | 0-2 |
Hours
|
LSD | 0-3 |
Minutes | MSD | 0-5 |
Minutes | LSD | 0-9 |
Seconds | MSD | 0-5 |
Secondss | LSD | 0-9 |
PIC Microcontroller binary
clock display hardware
(Click diagram to open a pdf)
Binary clock display | Red 8x8 LEDs matrix (for convenience) you only really need a 6x4 LED matrix and you can only buy an 8x8 or a 5x7! |
|
|
Compiler | Mikroelectronika MikroC Compiler Free! |
Target | 16F88/16F84 (retargetable to other PICs that have an enough pins). |
Software level | Easy. |
Software notes | Multiplexing the display/clock algorithm. |
Hardware level | Easy. |
Hardware notes | No special notes |
Project version | 1.01 |
Project files | Enter your details to get the Download Link and get the microcontroller newsletter: (Your email is safe it will never
be sold or rented). |
Compiler project
files
16F88-binary-clock.mcppi
C Source files.
16F88-binary-clock.c
Header files.
types.h
bit.h
Output files
16F88-binary-clock.hex
This contains all the code except :
The code is simple to follow and everything is done in main().
The multiplexing method is the same for the led matrix project so have a look there for the software description of that method.
The only difficult part is to correctly control the time display but its not that difficult as you can see in the code.
Note definitions FLIPLR and ROT180 allow you to alter the display orientation without re-wiring the board!
This project relies on the accuracy of the microcontroller's internal oscillator which is only 1% - and this is not very accurate at all. You can expect to loose ~15 minutes per day!
For a better accuracy use an external crystal as shown in some of the other projects. If you use a crystal the clock will be accurate to a few minutes per month.
Note: Even when using a standard crystal the board layout is very important - i.e. it will be a lot better than 1% but won't be as good as watch crystal accuracy.
You could use a DS1307 clock chip but even these accurate to about 2 seconds per day (loss) as they rely on a 20ppm watch 32kHz crystal - good track layout and correct capacitive crystal loading is needed to get the accuracy shown.
Clock source | Accuracy | Error per Day | Error per Month |
Internal oscillator | 1% | 14 minutes | 7 hours |
Standard crystal |
100ppm | 8.64 seconds | 4.32 minutes |
Watch crystal |
20ppm | 1.73 seconds | 51 seconds |
Jump from binary clock
to
Best-microcontroller-projects home page
With the ADXL345 acellerometer you can detect up to 16g! You can also find out how to use it for tap detection and more.
HMC5883L - How make a digital compass, Find out the differences between the HMC5883L and the QMC5883L and whether they are compatible.
Easily use an ESP8266 with the Arduino IDE and program your first sketch into the ESP8266
The MCP4725 chip is a 12 bit DAC with memory that outputs voltage that you can use for many dfferent purposes. Find out what they are in this page.
PCF8591: A four input ADC with single DAC. How good is this 8 bit ADC, and should you use it in your next project?
Arduino Nano ISP: How to program an ATmega328P using an Arduino Nano as the ISP programmmer. One common problem: Programming a sketch into the chip without a reset control - solved here.
New! Comments
Have your say about what you just read! Leave me a comment in the box below.