Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <Adafruit_Circuit_Playground.h>
  2. #include <Adafruit_CircuitPlayground.h>
  3.  
  4. volatile bool leftState = false, rightState = false;
  5.  
  6. void left()
  7. {
  8. if (CircuitPlayground.leftButton())
  9. leftState = !leftState;
  10. }
  11.  
  12. void right()
  13. {
  14. if (CircuitPlayground.rightButton())
  15. rightState = !rightState;
  16. }
  17.  
  18. void setup()
  19. {
  20. CircuitPlayground.begin();
  21. Serial.begin(9600);
  22.  
  23. attachInterrupt(digitalPinToInterrupt(4), left, CHANGE);
  24. attachInterrupt(digitalPinToInterrupt(5), right, CHANGE);
  25. }
  26.  
  27.  
  28. void loop()
  29. {
  30. Serial.print(leftState);
  31. Serial.print("t");
  32. Serial.print(rightState);
  33. Serial.print("n");
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement