Advertisement
j0h

read accell

j0h
Aug 6th, 2022
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #include <Adafruit_CircuitPlayground.h>
  2. #include <Mouse.h>
  3. #include <Wire.h>
  4. #include <SPI.h>
  5.  
  6. #define XACCEL_MIN 0.2 // Min range of X axis acceleration, wont move below
  7. #define YACCEL_MIN 0.2 // Min range of Y axis acceleration, wont move below
  8. #define XThreshold 3.0 //the sensor is noisy, ignore slight variations
  9. #define YThreshold 3.0
  10. #define ZThreshold 3.0
  11.  
  12. #define XSCREENSIZE 1280
  13. #define YSCREENSIZE 780
  14.  
  15. float x=0.0;
  16. float y=0.0;
  17. float z=0.0;
  18.  
  19. void setup() {
  20. CircuitPlayground.begin();
  21. Mouse.begin();
  22. Serial.begin(9600);
  23. }
  24.  
  25. void loop() {
  26. // Check if the slide switch is enabled (on +) and if not then just exit out
  27. if (!CircuitPlayground.slideSwitch()) {
  28. return;
  29. }
  30. boolean left_first = CircuitPlayground.leftButton();
  31.  
  32. //ok, we need resting position to be center of screen.
  33. float x1 = CircuitPlayground.motionX();
  34. float y1 = CircuitPlayground.motionY();
  35. float z1 = CircuitPlayground.motionZ();
  36. //if(z1)
  37. //now got think about this oh no...
  38. Serial.print("X: ");
  39. Serial.print(x);
  40. Serial.print(" Y: ");
  41. Serial.print(y);
  42. Serial.print(" Z: ");
  43. Serial.print(z);
  44. Serial.println();
  45. //move mouse to center
  46.  
  47.  
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement