hello,
you have a misplaced parenthesis and suppress the do.. while.
Code:
void main() {
TRISB= 0x00; //Configure PORTB as output
TRISA = 0xFF; //Configure PORTA as input
PORTB = 0x00; //LED OFF
while(1)
[B]{[/B] // Infinite loop
if(PORTA.F0==1)//If switch is pressed LED is ON endless
{
PORTB = 0x80; //Setting PortB as high
Delay_ms(100); // Maintain PortB as high for 100ms
PORTB = 0x40;
Delay_ms(100);
PORTB = 0x20;
Delay_ms(100);
PORTB = 0x10;
Delay_ms(100);
PORTB = 0x08;
Delay_ms(100);
PORTB = 0x04;
Delay_ms(100);
PORTB = 0x02;
Delay_ms(100);
PORTB = 0x01;
Delay_ms(100);
PORTB = 0x02;
Delay_ms(100);
PORTB = 0x04;
Delay_ms(100);
PORTB = 0x08;
Delay_ms(100);
PORTB = 0x10;
Delay_ms(100);
PORTB = 0x20;
Delay_ms(100);
PORTB = 0x40;
[B]Delay_ms(100);[/B]
PORTB = 0x80;
}
if (RA1_bit==1) //LED loop to stop if RA1 is pressed
{
PORTB= 0x00;}
}
[B]}[/B] // while
}
what happen if RA0 keep pressed and press RA1 in same time
you can add interlock condition
if((PortA.F0==1)&& (PortA.F1==0))
{
moving led
}
if ((PortA.F1==1)&&(PortA.F0==0))
{
PortB=0;
}