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.
Thanks for any help
Something like this would probably work
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
Was unable to complile the code.
CountButton ++ Is giving me an error
In EasyC I used the User Code to put this part in. Should I use something else?
You should use Assignment but if you use user code all lines of C should end with “;”