Guest User

Untitled

a guest
Jul 18th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. /*
  2. Example of single fire actions
  3.  
  4. 07.18.2018
  5. by Jonathan Bobrow
  6.  
  7. */
  8.  
  9. #include "Serial.h";
  10.  
  11. ServicePortSerial Serial;
  12.  
  13. byte buttonState = 0;
  14.  
  15. enum State {
  16. UP,
  17. DOWN
  18. };
  19.  
  20. void setup() {
  21. // put your setup code here, to run once:
  22. Serial.begin();
  23. }
  24.  
  25. void loop() {
  26. // put your main code here, to run repeatedly:
  27.  
  28. if (buttonDown()) {
  29.  
  30. // print the button is down once
  31. if (buttonState == UP) {
  32. // print we are now down
  33. Serial.println("button is now down");
  34. }
  35. buttonState = DOWN;
  36. }
  37. else {
  38. // print the button is now up once
  39.  
  40. if (buttonState == DOWN) {
  41. // print we are now up
  42. Serial.println("button is now up");
  43. }
  44. buttonState = UP;
  45. }
  46. }
Add Comment
Please, Sign In to add comment