I am trying to program in EasyC how to count an if loop. I want the count to count after 3 times of pressing the bump switch that it moves/jumps to a different line of code. I am new to using EasyC please feel free to bring it down to my level.
void main ( void )
{
char Button = 1;
char ButtonLast = 1;
char CountButton = 0;
while ( 1 ) // Loop Forever - Place Operator Code in this Loop
{
Button = GetDigitalInput ( 1 ) ; // Get Button Status
if ( Button == 0 && ButtonLast == 1 ) // If Button is Pressed and Wasn't Before
{
CountButton ++ ; // Add 1 to the variable Countbutton
Wait ( 20 ) ; // debounce the button a bit
}
ButtonLast = Button ; // Set the ButtonLast variable to the current value of Button
if ( CountButton >= 3 ) // if Countbutton is greater than or equal to 3
{
// Do Something
}
}
}