PIC16F877 up down counter code and Proteus simulation
This PIC16F877 microcontroller tutorial answers the question,
” How to implement a up down counter using PIC16F877 ? “
Using PIC16 simulator (Proteus) you can verify this counter code and change it according to your needs. Using one push button (Labeled as Count, as shown in figure below) you can increment (When SW1 switch is towards up position) or decrement (When SW1 switch is towards down position) count value (displayed on LCD) as you desire. 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.
The following diagram (made in Proteus) shows the PIC microcontroller circuit diagram.
The above figure was taken after pressing Count button 4 times. SW1 switch position is set towards ‘Up’ position, hence count value was incremented with each press of Count button. LCD is updated with the new value of count after every 200 milli second.
You can set SW1 switch to ‘Down’ position and then after pressing Count button, count value will decrement. When count value reaches 100 then it resets to 0 value again.
A crystal of 20MHz value is used in this circuit, which makes this PIC16F877 run at a speed of 5MIPS (Million of instructions per second). You can use any other value of crystal ( From 0 to 20 MHz value only) as well.
The main function code is shown below.
If you have benefited from my blog then please consider donating some money to me, so that I can continue producing more free content for you.
Up down counter 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 up down counter code and Proteus simulation
EasyEDA: Ideas for Circuit Design, Innovation for Electronics Access
Free Circuit Design: Schematic – Simulation – PCB Layout – Gerber Viewer
Cheapest PCB Prototype: Only $2 for 10pcs 10×10cm PCBs, 24 hours Quick Turn, DHL Delivery in 3 Days
Current Project / Post can also be found using:
- bidirectional visitor counter using pic16f877a
- 7segment up down counter program on pic mocrocontroller
- bidirectional visitor counter using pic
- bidirectional visitor counter circuit dig 16f877