Ive been working on some code that has 2 buttons to move a variable up or down by one and a button ot reset it to zero. After struggling for some time i made it work my multiplying the variable by zero if the conditions are met. Theres got to be a better way of doing this just curious what it is?
This is a sample of the code ive been using.
Thanks!
if (NextState != lastNextState){
if (NextState == LOW){
buttonPushCounter++;
}
delay(200);
}
lastNextState = NextState;
if (PrevState != lastPrevState){
if (PrevState == LOW){
buttonPushCounter--;
}
delay(200);
}
lastPrevState = PrevState;
if (ClearState != lastClearState){
if (ClearState == LOW){
buttonPushCounter *= 0;
}
delay(200);
lastClearState = ClearState;