Advertisement
aaron83

Untitled

Oct 27th, 2017
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <AnalogSmooth.h>
  2.  
  3. int analogPin = A0;
  4.  
  5. // Defaults to window size 10
  6. AnalogSmooth as = AnalogSmooth();
  7.  
  8. // Window size can range from 1 - 100
  9. AnalogSmooth as100 = AnalogSmooth(100);
  10.  
  11. void setup() {
  12. Serial.begin(9600);
  13. }
  14.  
  15. // the loop routine runs over and over again forever:
  16. void loop() {
  17. float analog = analogRead(analogPin);
  18. // read the input on analog pin 0:
  19. int sensorValue = analogRead(A0);
  20. // print out the value you read:
  21. Serial.println(sensorValue);
  22. //delay(1); // delay in between reads for stability
  23. if (sensorValue < 481)
  24. {Joystick.X(1);
  25. }
  26. else
  27. Joystick.X(0);
  28. if (sensorValue > 539)
  29. {Joystick.X(-1);
  30. }
  31. else
  32. Joystick.X(0);
  33.  
  34. delay(100);
  35. {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement