Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int joyx = 0;
- int joyy = 0;
- int joyz = 0;
- int deadx = 100;
- int deady = 100;
- int deadz = 100;
- void setup() {
- Serial.begin(9600);
- Joystick.useManualSend(true);
- }
- void loop() {
- joyx = (analogRead(14)-522)*(512/100);
- joyy = (analogRead(15)-512)*(512/100);
- if(abs(joyx) < deadx) joyx = 0;
- if(abs(joyx) > 512) joyx = 512 * (joyx / abs(joyx));
- if(abs(joyy) < deady) joyy = 0;
- if(abs(joyy) > 512) joyy = 512 * (joyy / abs(joyy));
- Serial.println(String(joyx) + " " + String(joyy));
- Joystick.X(abs(-512+joyx));
- Joystick.Y(abs(-512+joyy));
- Joystick.send_now();
- delay(5);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement