Skip to content

Instantly share code, notes, and snippets.

@jbobrow
Created July 18, 2018 21:49
Show Gist options
  • Save jbobrow/10bd9d77e450d5229ef3215f28c90552 to your computer and use it in GitHub Desktop.
Save jbobrow/10bd9d77e450d5229ef3215f28c90552 to your computer and use it in GitHub Desktop.
Blinks - Single Fire Action Example
/*
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