Second and Minute Counter using PIC16F877A - PIC Programming - Proteus Simulation - MPLB C Code
Problem - Second and Minute Counter using PIC PIC16F877A micro-controller.
Software Support - MPLAB IDE for C programming,Proteus for simulation purpose.
Components - PIC 16F877A- Micro controller,LED arrays,External clock.
Theory :-
We have two sets of LED arrays, one for displaying seconds and other for minutes.Both arrays has six LEDS each,since up to sixty must be counted.An external clock is used here,it will configure each counter increment by one second.
Sixth pin serves external clock pulses,it will make a delay of one second on each count.LED arrays for second counting is given in port B,arrays for minute counting in port D.Each LED is given a series resistance to control voltage.
Into the code, First,timer zero made reset then it is turned on by control register.The counting value is given to port B.When it approaches sixty port D is incremented and counter resets.
Circuit Setup :-
Program:-
#include<pic.h> //PIC header file
void main()
{
TRISB=0; //Port B as output
TRISD=0; //Port D as output
PORTD=0;
TMR0=0; //Resets timer
OPTION=0X28; //Timer 0 start
while(1)
{
PORTB=TMR0; //Seconds count
if(TMR0==60)
{
TMR0=0;
PORTD+=1; //Minute count
if(PORTD==60)
PORTD=0;
}
}
}
For more PIC 16F877A programs - click here