PIC16F877 up down counter code and Proteus simulation




This PIC16F877 microcontroller tutorial answers the question,
” How to implement a up down counter using PIC16F877 ? “

Proteus simulation

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.

PIC16F877 up down counter code and Proteus simulation Schematic

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.

Code

The main function code is shown below.

Downloads

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




Current Project / Post can also be found using:

  • thermometer-coded up/down counter
  • visitor counter using pic
  • bidirectional visitor counter using pic 16f877a
  • bidirectional visitors counter circuit for 100 visitors

Leave a Comment

*
= 5 + 4

Read previous post:
PIC16f877 based simple calculator
PIC16f877 based simple calculator project

This PIC microcontroller tutorial provides a simple calculator implementation for PIC16F877 microcontroller. This is a simple one digit[1] calculator which implements...

Close
Scroll to top