Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 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;
- }
- }
Add Comment
Please, Sign In to add comment