I'm trying to create a simple 2 axis joystick using my Teensy 3.1 and a Arduino Compatible X and Y Axis Joystick Module (image below). I have the GND connected to the AGND, the +5V connected to the Vin (also tried 3.3V), the VRX connected to A0 and the VRY connected to A3. I have the Teensy set to keyboard + mouse + joystick and I'm using the following code which is the basic USB joystick example.
Windows 10 detects the joystick successfully in Game Controllers (joy.cpl) but when I go into properties to check the operation the + symbol in the X Axis / Y Axis box is jumping all over the place. Moving the pot joystick doesn't seem to make much difference. Can anyone see what I might be doing wrong? Is there anything I need to add or change for the analogRead command?
I really appreciate any help I can get. Thanks
Code:
void setup() {
pinMode(0, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
}
void loop() {
Joystick.X(analogRead(0));
Joystick.Y(analogRead(3));
// a brief delay, so this runs 20 times per second
delay(50);
}
Windows 10 detects the joystick successfully in Game Controllers (joy.cpl) but when I go into properties to check the operation the + symbol in the X Axis / Y Axis box is jumping all over the place. Moving the pot joystick doesn't seem to make much difference. Can anyone see what I might be doing wrong? Is there anything I need to add or change for the analogRead command?
I really appreciate any help I can get. Thanks