Using microcontroller PIC 16F887 to control 8 single leds on and off using timer T1 with period delay is 2s, 1 second on, 1 second off
- Circuit diagram Interface PIC16F887 microcontroller with LED on Proteus software:
Figure 1. PIC16F887 microcontroller interface with LED |
- Main program:
__________________
#INCLUDE <16F887.H>
#FUSES NOWDT,PUT,HS,NOPROTECT,NOLVP
#USE DELAY(CLOCK=20M)
#BIT TMR1IF = 0x0C.0
UNSIGNED INT8 X, BDT;
VOID MAIN()
{
SET_TRIS_D(0x00); X=0; BDT=0; OUTPUT_D(X);
SETUP_TIMER_1(T1_INTERNAL | T1_DIV_BY_8);
SET_TIMER1(3036);
WHILE(TRUE)
{
IF (TMR1IF==1)
{
TMR1IF=0; SET_TIMER1(3036); BDT++;
IF (BDT ==10)
{
OUTPUT_D(X); X=~X; BDT = 0;
}
}
}
}
__________________
Comments
Post a Comment