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
From Schematic to PCB Production, Just Need One Tool
Free Circuit Design Software: learn to use Editor quickly and easily
Cheapest PCB: 10pcs 2-layers 10cm×10cm only $8.21, 3-day build time, 100% E-test
Current Project / Post can also be found using:
- 7segment up down counter program on pic mocrocontroller
- bidirectional visitor counter circuit dig 16f877
- 7segment up down counter code using pic16 contriller
- 7segment up down counter using pic16f887