hi am working on pic16f877a , have interfaced pushbutton . If the button is pressed once value will increment by 1 . But, if I press down and hold for long time value should increment fastely . Below is the code for button and am using XC8 complier.
void main()
{
int oldstate;
oldstate = 0;
while(1)
{
if(RA4 == 1) // switch
{
oldstate = 1; // update flag
}
if(oldstate &&(RA4 == 0))
{
val++;
if(val > 10)
{
val = 1;
}
oldstate = 0; // update flag
}
}
}