DIY FSX yoke+throttle quadrant - help with 6 axis

Hello, this is my first project using Arduino (I got Arduino Uno ATMEGA328P-PU).
I’m trying to built a throttle quadrant and yoke for Flight Simulator. The throttle quadrant has 4 axis (2 throttle - 1 prop - 1 mixture) and the yoke 2 axis (forward/backward and left/right rotation).

I found this sketch on the internet, actually it’s for EURO TRUCK 2, but I think it will suit. I need some help to unlock all the 6 analog ports, it’s set to use only 3 of them.

sketch_aug19c.ino (4.29 KB)

I need some help to unlock all the 6 analog ports, it's set to use only 3 of them.

The other ports are not locked. They are just not used. That code does some really bizarre crap as far as reading the analog pins, which you will need to sort out.

Hmm, I see.
I found this other one, it’s pretty similar, but maybe better, tho?

sketch_flight.ino (6.49 KB)

but maybe better, tho?

No. The fact that octal constants are used unnecessarily means that someone doesn’t really understand what they are doing.

The initial values for the axis array in the joyReport object are stupid.

// turn a button on

Look at the buttons on your shirt. What turns them on? Does such a thing make ANY sense? Turning a switch on is a different story. Microcontrollers READ switches, though. They do NOT turn switches on.

Of course, that code doesn’t actually turn a switch on, so the comment is just plain stupid.

  for (int bt = 1; bt < 13; bt ++)
    btn[bt] = digitalRead(bt + 1); // reads pins D2-D13

Array indices start at 0.

uint8_t btn[13]; // fix riclamer's [12] dimension to [13]

The only “reason” that is needed fixing was because someone didn’t understand that arrays start at 0, not 1.

Other than that, the handling of the analog pins is correct - each is read exactly once. What is wrong, though is the assumption that only 3 pins are used, and that the other 5 values in the array should be set to 0. There SHOULD be a #define or const byte statement that defines how many analog pins are used, and the rest of the values in the array should be left at their initial, meaningful, values.