Arduino values are not read by driver station?

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:

#include “Joystick.h”

Joystick_ Joystick;

const bool testAutoSendMode = true;

void setup() {
bool includeXAxis = true;
bool includeYAxis = true;
bool includeZAxis = true;
bool includeRxAxis = true;
bool includeRyAxis = true;
bool includeRzAxis = true;
bool includeRudder = true;
bool includeThrottle = true;
bool includeAccelerator = true;
bool includeBrake = true;
bool includeSteering = true;

if (testAutoSendMode)
{
Joystick.begin();
}

}

void loop() {
int analogValue = analogRead(A1);
int analogValue1 = analogRead(A2);
Joystick.setXAxis(analogValue);
Joystick.setYAxis(analogValue1);

Serial.print(analogValue);
Serial.print(", ");
Serial.println(analogValue1);

}

Please let me know if you have any ideas or need more information as I have been stuck on this issue for a while.

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:

  1. 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.
  2. 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.

1 Like

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.

windows does recognize and display the axis values.

this is the driver station:

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.

do you mean that you can read the values of the axes on driver station?

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.

great, thank you! :smiling_face:

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.

I’ve had this same issue where it only showed the buttons on the driver station when we wanted the axis values never figured it out.

yes, I have tried this with a button and it will show on driver station but still no axes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.