crazy-igzp
Member level 1
- Joined
- Feb 3, 2014
- Messages
- 34
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 6
- Location
- Settat, Morocco
- Activity points
- 255
hi !
I'm trying to to make a led light on when i push the button !
here is the situation :
- when I push it for the first time, the led lights and switch off after a delay ! but if I push it the second time and she's still lights ( in the delay ) it should turn off
I made this prog ! but it didn't work ! I forgot to mention I'm working on pic16f877
help ! were is the problem ?
I'm trying to to make a led light on when i push the button !
here is the situation :
- when I push it for the first time, the led lights and switch off after a delay ! but if I push it the second time and she's still lights ( in the delay ) it should turn off
I made this prog ! but it didn't work ! I forgot to mention I'm working on pic16f877
Code:
[syntax=c]int b,a=0;
void interrupt() {
if (INTCON.INTF) {
portc.b0=0;
b=5;
INTCON.INTF=0;
}
}
void main()
{
trisb=0xFF;
trisC=0x02;
INTCON=0x90;
aa :
a=0;
b=0;
portc.b0=0;
//-----------------------
for(;;)
{
if(portb.B1==0)
{
portc.b0=1;
for(;;)
{
delay_ms(20);
a++;
if(b==5)
{
goto aa;
}
if(a==100)
{
goto aa;
}
}
}
}
}[/syntax]
help ! were is the problem ?