PIC16F877 based digital clock using LCD display (Code+Proteus simulation)




This PIC16F877 microcontroller tutorial answers the question,
” How to implement a digital clock using PIC16F877 ? “

PIC16F877 based digital clock using LCD display

Using PIC16 simulator (Proteus) you can verify this digital clock code and change it according to your needs. This code is written in C language using MPLAB with HI-TECH C compiler. You can download this code from the ‘Downloads‘ section at the bottom of this page.

In this article, it is assumed that you know,

  • How to interface LCD with PIC16F877 microcontroller. If you don’t then please read this page.
  • How to configure timer0 of PIC16F877 microcontroller.  If you don’t then please read this page.

The following diagram (made in Proteus) shows the PIC microcontroller circuit diagram.

The above figure was taken after 2 minute and 59 seconds of code simulation in Proteus. In the code, timer0 is used as the base for digital clock generation. Timer0 is used here to generate 1msec interrupts. After every 1msec a global variable named msCounter increments. When msCounter reaches a value of 1000 then another global variable named secCounter increments and this process repeats itself. Similarly, when secCounter reaches 60, then  minCounter increments. And when minCounter reaches 60 then hrCounter increments. This process continues until hrCounter reaches 24 then all of these variables reset their values. LCD is updated with the new values of hrCounterminCounter and secCounter after every second.

PIC16F877 based digital clock using LCD display schematic

A crystal of 4MHz value is used in this circuit, which makes this PIC16F877 run at a speed of 1MIPS (Million of instructions per second).

Code

The main function code is shown below.

Downloads

Digital clock display code using PIC16F877 was compiled in MPLAB v8.85 with HI-TECH C v9.83 compiler and simulation was made in Proteus v7.10. To download code and Proteus simulation click here.

 

For more detail: PIC16F877 based digital clock using LCD display (Code+Proteus simulation)




Current Project / Post can also be found using:

  • digital clock using pic and 7 segment display
  • digital clock using pic16f877a
  • clock with pic ccs source code
  • digital clock using pic

Leave a Comment

*
= 5 + 0

Read previous post:
Interfacing keypad with PIC16F877
How to interface keypad with PIC16F877

This PIC microcontroller tutorial provides a simple method to interface any keypad (e-g 4x4 or 4x3 etc) with PIC16F877 microcontroller. This...

Close
Scroll to top