I have this code. What i am trying to do is using the interrupt function and then if gpi2 is positive, it blincks..
Right now i have a wire on gpi2 and every time i touch it the 'blinck()' goes of, or even a bump on my table makes it go off...
Any idea on how to fix it?
Pic: 12f683
Compiler: microC
Right now i have a wire on gpi2 and every time i touch it the 'blinck()' goes of, or even a bump on my table makes it go off...
Any idea on how to fix it?

Pic: 12f683
Compiler: microC
Code:
int i = 0;
void blink(void)
{
for(i = 0; i<4;i++)
{
GPIO.B0 = 1;
delay_ms(100);
GPIO.B0 = 0;
Delay_ms(100);
}
}
void interrupt(void)
{
if(INTCON.GPIF == 1 && GPIO.B2 == 1 )
{
INTCON.GIE = 0;
blink();
INTCON.GPIF = 0;
INTCON.GIE = 1;
}
else
{
}
}
void main() {
TRISIO = 0b00000100;
CMCON0 = 0x07;
ANSEL = 0;
ADCON0 = 0;
INTCON.GIE = 1;
INTCON.GPIE = 1;
IOC.IOC2 = 1;
while(1)
{
}
}
Last edited: