Advertisement
Guest User

Untitled

a guest
Dec 16th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. // read the pushbutton input pin:
  2. buttonState = !digitalRead(buttonPin);
  3. // If buttonstate changes, increment the counter
  4. if (buttonState != lastButtonState) {
  5. if (buttonState == HIGH) {
  6. previousMillis = currentMillis;
  7.  
  8. buttonPushCounter++;
  9. // If the counter reaches 16, reset to 0.
  10. if (buttonPushCounter >= 16) {
  11. buttonPushCounter = 0;
  12. }
  13. }
  14. // Delay a little bit to avoid bouncing
  15. delay(50);
  16. // save the current state as the last state, for next time through the loop
  17. lastButtonState = buttonState;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement