Arduino toggle button
So this is the code I made A toggle button with.
So when I press the button, the counter stays on 1 and when i press again it goes to 0.
But Im actually not sure how this works exactly, I cant bring my self to understand, could somebody smart kinda explain the process here?
if(buttonState==HIGH && oldButtonState==LOW) {
counter++;
}
if(counter>1) {counter=0;}
oldButtonState=buttonState;
}
thanks!
6 Replies
Ok so its a lock out.
You can NOT get into the first if statment. Unless the seccone one was the last one to take place.
And same with the seccond one.
@TheStudier
hmm
Its kinda incomplete but that's the premise
okay thanks Ill try to figure it out
so when I press the button
and keep it pressed, shouldn't the counter just grow a lot
why does it stay at 1
Because it cant
If its over 1 its set back to 0
true