I am VERY VERY new at writing code and am basically trying to teach myself C
I am writing a routine to push a button and an LED will come on for a short period then switch off. What I am wanting to add now is that when the button is pushed the output is checked first. If it is high it ignores the push button if low it goes high.
I have no idea how
My code thus far is
I am writing a routine to push a button and an LED will come on for a short period then switch off. What I am wanting to add now is that when the button is pushed the output is checked first. If it is high it ignores the push button if low it goes high.
I have no idea how
My code thus far is
Rich (BB code):
if(SW1==0)// switch pushed
{ __delay_ms(100); // debounce delay
}
if(SW1==0)// switch still pushed
{
LED=1;// turn on LED1
__delay_ms(1000); //Delay
LED1=0; //Turn LED1 off
}