I am working on pic16f877a and using XC8 complier. Have interfaced pushbutton if I press the button value should increment by 1.. its working fine but one more condition - If I keep press and hold down for long time fastely value should increment how to do this I dont no am trying but not achieved. Below is my button code
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
}
}
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
}
}