SHARE
TWEET

Untitled

a guest Jun 17th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top