PIC16f887 Source code to operate relay, LED (anything) no. of times with interrupt
PIC16f887 micro controller is a 8 Bit CMOS micro controller with nano Technology from the company Microchip having High-Performance RISC CPU and several other special features . In this project , we shall interface LED , relay , buzzer or anything which can act as output with the Micro Controller PIC16f887 .
The main motive is that for every interrupt we give to micro Controller , it will give that much particular no. of times the total output at our desired configured pin . According to the source code of the program , you need to interface switch "push button" on portb as input while on portc , connect anything which can act as output .
Just copy the following source code int the software "PIC C compiler" named as PCWHD and compile it . After the compilation , you will get the converted "hex" file of your written code . Just flash or burn the hex file onto your micro controller using usb 2.0 Programmer or by any other way you want .
Now for each time you press the switch , it will count the total no. of times the switch has been pressed , and it will give output for that much no. of times . For example , I pressed the switch 5 times , The LED will then Glow 5 times .
#byte portb= 0x06
#byte trisb= 0x86
#byte portc= 0x07
#byte trisc= 0x87
unsigned int32 i=0,j=0,m=0,k=0;
void main ()
trisc = 0x00;
portc = 0x00; //off
trisb = 0x01;