Created
July 18, 2018 21:49
-
-
Save jbobrow/10bd9d77e450d5229ef3215f28c90552 to your computer and use it in GitHub Desktop.
Blinks - Single Fire Action Example
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
/* | |
Example of single fire actions | |
07.18.2018 | |
by Jonathan Bobrow | |
*/ | |
#include "Serial.h"; | |
ServicePortSerial Serial; | |
byte buttonState = 0; | |
enum State { | |
UP, | |
DOWN | |
}; | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
if (buttonDown()) { | |
// print the button is down once | |
if (buttonState == UP) { | |
// print we are now down | |
Serial.println("button is now down"); | |
} | |
buttonState = DOWN; | |
} | |
else { | |
// print the button is now up once | |
if (buttonState == DOWN) { | |
// print we are now up | |
Serial.println("button is now up"); | |
} | |
buttonState = UP; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment