I am using an Arduino Leonardo to create a custom joystick involving 2 potentiometers communicated as the x and y axes. My windows control panel will recognize the Leonardo as a game controller as well as read the x and y axis values. My issue is that the driver station will see the Leonardo and display it as a USB device but it will not read any of the values.
I am using the Arduino joystick library found here:
and this is the code that is currently on my Arduino:
You say windows recognizes it as a game controller. Does windows show axis values as well? If so, what does the USB tab of the driver station app look like? (Screenshot welcomed)
Here is the code that 3468 used a few years ago without issue:
Some things that come to mind:
Serial uses the USB as well, and could be causing conflict with the Joystick HID comms. Maybe try removing/commenting out the Serial.print calls.
You don’t have any delay in your loop, possible you’re sending too much data and that could cause problems, a 10ms delay could resolve that and still be much faster polling than a human could respond to.
IDK if Windows has a built in Gamepad/Joystick tester/viewer, but if so check that out as well and see if the data is coming through there.
I was able to run your project without modification and it seems to be working just fine as both a joystick (visible in the simulator) even while it is printing your serial output to the console.
I have used a different joystick library for Arduino in the past. I don’t think the one you have is the one I got through the Library Manager. I have found in my other projects that the joystick can become unresponsive if I overtask the Arduino doing other tasks.
I tried commenting out the Serial.print lines as well as adding a 50ms delay and neither of them worked. Additionally, the data is shown through the windows gamepad viewer.
Not exactly. I tested it on my mac under simulation, so into Glass. I realize that’s not quite the same test, but it worked well here. Yes, it could read two analog joystick axes.
I’ll be able to test this on our drive station in a little while. I’ll let you know what I find.
We only had a little time to test this, but the device wasn’t even showing up as a joystick on our drive station. It might be a missing driver. Unfortunately, we had other stuff to work on and couldn’t troubleshoot.
We are working on something similar, so we’ll post our solution if/when we get it working reliably.