#define BUTTON1 RA0 // pushed - 0, released - 1
#define LED1 RA1
LED1 = 1; // turn LED on
start :
if (BUTTON1 == 0) //pushed
{
DelayMs(100); // delay for 100 milliseconds
while (BUTTON1 == 0)
{ //wait while pushed
}
DelayMs(100); // delay for 100 milliseconds
LED1 = !(LED1); // turn LED on/off
}
goto start;
But there are some stuff that I didn't take into account, and therefor it works wrong. Sometimes when I click the button LED don't torn off/on. And sometimes LED switches when I do not touch the button.