Created
February 28, 2016 16:33
-
-
Save joneskoo/c288ca30a25c67dd892f to your computer and use it in GitHub Desktop.
Door bell glitch removal bugfix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void loop() { | |
int oldButtonState = digitalRead(buttonPin); | |
// Wait for button to be pressed | |
while (1) { | |
int buttonState = digitalRead(buttonPin); | |
// Button state changed | |
if (buttonState != oldButtonState) { | |
// glitch removal - wait GLITCH_US and if button state still | |
// changed, proceed | |
delayMicroseconds(GLITCH_US); | |
+ buttonState = digitalRead(buttonPin); | |
if (buttonState != oldButtonState) { | |
break; | |
} | |
} | |
} | |
… |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment