Is it possible 7 axis?

Hello guys.

I made an arduino code for joystick with mixed codes found in web and it has worked very nice to me, code below:


int pinos [] = {
  0,1,2,3};

  int lastButtonState[32] = {0,0,0,0};

#include "Joystick.h"

Joystick_ Joystick(
  JOYSTICK_DEFAULT_REPORT_ID,
  JOYSTICK_TYPE_JOYSTICK,
     32, // +2 for the rotary encoder elevator trim
      0,
   true,  // includeXAxis       1
   true,  // includeYAxis       2
   false,  // includeZAxis       3
   true,  // includeRxAxis      4
   true,  // includeRyAxis      5
  false,  // includeRzAxis      6
   true,  // includeRudder      7
   true,  // includeThrottle    8
  false,  // includeAccelerator
  false,  // includeBrake
  false); // includeSteering

  void setup() {

  Joystick.setXAxisRange(0, 1023);
  Joystick.setYAxisRange(0, 1023);
  Joystick.setRudderRange (0, 1023);
  Joystick.setThrottleRange (0, 1023);
  Joystick.setRxAxisRange (0, 1023);
  Joystick.setRyAxisRange (0, 1023);

    
    for(int i=0; i<4; i++){
  pinMode(pinos[i],INPUT_PULLUP);
  }
       
    
    Joystick.begin();   

}

void loop() {

Joystick.setXAxis (analogRead(A2));
Joystick.setYAxis (analogRead(A3));
Joystick.setRudder (analogRead(A1));
Joystick.setThrottle (analogRead(A0));
Joystick.setRxAxis (analogRead(A7));
Joystick.setRyAxis (analogRead(A6));

for (int index = 0; index < 4; index++)
  {
    int currentButtonState = map(digitalRead(index + 0),HIGH,LOW,LOW,HIGH);
    
    
    if (currentButtonState != lastButtonState[index])
    {
     Joystick.setButton(index, currentButtonState);
      lastButtonState[index] = currentButtonState;    
    }   
  }  
}

The question is: It would be nice to my gaming experience, to be able to add another analogic control.

If I change the line of Rzaxis to true, it works (potentiometer conected in #8 input of arduino micro), but in panel of gaming controllers of windows the rudder desapear. New controller is working (Rzaxis), and rudder is not more available. I have tryed with all other analogics, and got the same results.

What seems is that, is not possible to have more than 6 analogic inputs.

What could I do for having this 7th analogic controller?

Thanks.

The Arduino Leonardo provides 12 analog inputs. In addition to A0-A5, the additional inputs are configured as follows:
A6 – A11on digital pins 4, 6, 8, 9, 10, and 12

Test the joystick with a HID viewer to verify if all axes are being reported. This will confirm whether the issue is with Windows Game Controller Panel or the HID descriptor.

Hello. Thanks for advice. Its clear to me. The point is: How to add the 7th analog input to my joystick, without losing rudder.

Many of the Arduino boards have a limit of 6 analog inputs. You either need to use a different board such as the Leonardo or Arduino Micro which offers 12 analog inputs, or a more complicated scheme that uses a multiplexer chip (with i2c or SPI).

I am assuming you used a UNO as you did not specify. Switch to the original Nano and it has two more analog inputs.

Mine is arduino Micro. When I conect the 7th analog input, it works very nice. My problem is other analog stops to work. The rudder.

Mine is pro micro, and the 7th analog input worked very nice, but I lost other analog: rudder.

The next step is to post an annotated schematic showing exactly how you have wired this. Be sure to include all power, grounds, power sources, external components etc. Frizzies are wiring diagrams not schematics.

If I understood well, The circuit does not matter, you could have nothing connected and generate random numbers for the analog values.

the issue seems to be that the PC does not recognize the HID descriptor so that’s where I would dig first.

I don’t know that library well enough but a Quick Look at the source code shows that they build the descriptor dynamically so that should be fine as long as there is no RAM issue on the arduino side.

J-M-L, you are right. I understand cirquit is working very well.

Please, take a looked at this image, this is the gaming controllers of windows:

I have 6 axis working very well: X and Y Axis, Acelerator, X and Y rotation axis, and rudder.

When I add an extra analog input Z rotation, the rudder get out of this screen and Z rotation take its place, and work very nice. The potentiometers go up and down normally, but in this managing of game controllers, the Rudder (Leme in portuguese), desapear.

The question is: Is not possible to have a joystick with 7 analogic inputs?

Thanks.

I don't know windows well enough to answer the question.

As I said earlier, you should look for a HID viewer or command line tool to verify if all axes are being reported correctly

Can you please recomend me a HID viewer? Typing on google, did not find a conclusive result.

Thanks.

I don't use windows. On linux you have command lines like lsusb and usbhid-dump