Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // read the pushbutton input pin:
- buttonState = !digitalRead(buttonPin);
- // If buttonstate changes, increment the counter
- if (buttonState != lastButtonState) {
- if (buttonState == HIGH) {
- previousMillis = currentMillis;
- buttonPushCounter++;
- // If the counter reaches 16, reset to 0.
- if (buttonPushCounter >= 16) {
- buttonPushCounter = 0;
- }
- }
- // Delay a little bit to avoid bouncing
- delay(50);
- // save the current state as the last state, for next time through the loop
- lastButtonState = buttonState;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement