Guest User

Untitled

a guest
Jul 10th, 2018
491
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int joyx = 0;
  2. int joyy = 0;
  3. int joyz = 0;
  4.  
  5. int deadx = 100;
  6. int deady = 100;
  7. int deadz = 100;
  8.  
  9. void setup() {
  10. Serial.begin(9600);
  11. Joystick.useManualSend(true);
  12. }
  13.  
  14. void loop() {
  15. joyx = (analogRead(14)-522)*(512/100);
  16. joyy = (analogRead(15)-512)*(512/100);
  17.  
  18. if(abs(joyx) < deadx) joyx = 0;
  19. if(abs(joyx) > 512) joyx = 512 * (joyx / abs(joyx));
  20.  
  21. if(abs(joyy) < deady) joyy = 0;
  22. if(abs(joyy) > 512) joyy = 512 * (joyy / abs(joyy));
  23.  
  24. Serial.println(String(joyx) + " " + String(joyy));
  25.  
  26. Joystick.X(abs(-512+joyx));
  27. Joystick.Y(abs(-512+joyy));
  28.  
  29. Joystick.send_now();
  30. delay(5);
  31. }
RAW Paste Data