Arduino micro joystick pot limit?

I'm working on a flight sim joystick using the joystick.h library. I've gotten 7 pots initialized and working correctly, x,y,z,rx,ry,rz,rudder, however when i initialize the 8th pot throttle. rudder dissapears and no longer works. is there a limit to how many pots joystick can use? the micro should have 12 analog inputs so i was hoping to use 9 pots for flight surfaces and 3 switches for various other needs

//REVIEW ALL TABS FOR INFORMATION ABOUT WIRING AND COMPLETE BUILD GUIDE!!!
#include <Keypad.h>
#include <Joystick.h>

//Potentiometer Setup
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_JOYSTICK,
  0, 0,                  // Button Count, Hat Switch Count
  true, true, true,     // X, Y, and Z Axis
  true, true, true,     // Rx, but no Ry or Rz (Rx represents throttle as fs2020 does not recognize the throttle axis!)
  true, true,          // No rudder or throttle (represented as Rx!)
  false, false, false);  // No accelerator, brake, or steering; 
int XAxis = 0;
int YAxis = 0;
int ZAxis = 0; 
int RxAxis = 0;
int RyAxis = 0;
int RzAxis = 0; 
int Rudder = 0;
int Throttle = 0;


void setup(){
  Joystick.begin(); //Starts joystick
}
  
void loop(){
  
  XAxis = analogRead(A0);
  XAxis = map(XAxis,0,1023,0,255);
  Joystick.setXAxis(XAxis);
  
  YAxis = analogRead(A1);
  YAxis = map(YAxis,0,1023,0,255);
  Joystick.setYAxis(YAxis);

  ZAxis = analogRead(A2);
  ZAxis = map(ZAxis,0,1023,0,255);
  Joystick.setZAxis(ZAxis);

  RxAxis = analogRead(A3);
  RxAxis = map(RxAxis,0,1023,0,255);
  Joystick.setRxAxis(RxAxis);

  RyAxis = analogRead(A4);
  RyAxis = map(RyAxis,0,1023,0,255);
  Joystick.setRyAxis(RyAxis);

  RzAxis = analogRead(A5);
  RzAxis = map(RzAxis,0,1023,0,255);
  Joystick.setRzAxis(RzAxis);

  Rudder = analogRead(A6);
  Rudder = map(Rudder,0,1023,0,255);
  Joystick.setRudder(Rudder);

  Throttle = analogRead(A7);
  Throttle = map(Throttle,0,1023,0,255);
  Joystick.setThrottle(Throttle);
 
  delay(5);
}

I have never used the joystick library... Check the documentation for its limits, the number of channels.

How do You know that from the code You post? Crystal ball? Joking! But I see no Serial.print or similar debug signalling.

i don't see anything on the main github and not sure where else i would find that in the github. i noticed in the set-up usb game controller and properties. i have yet to use serial monitor/ploter. i will look into how to get that to work

I assume You refer to checking up the library. Such documentation would most likely be found within the library files, not "in the club".

You really got it! That's the way to debug code. Serial.print of critical/interesting variables and thereby pin point the eventual mishap is the way to go.
It's very powerful. During my professional time I was often thrown into new, large, unknown systems but managed to crack every nut being given using temporary debug print outs.
Still, what makes You think things hang up when using pot8? Start by using pot 8, pot 7 etc. What happens then?

Why are you mapping to the 0-255 range when the library, by default, expects ranges of 0-1023? You won't be able to go more than 25% on any axis.

You can simplify your sketch quite a bit by eliminating the mapping:

  Joystick.setXAxis(analogRead(A0));
  Joystick.setYAxis(analogRead(A1));
.
.
.
  Joystick.setThrottle(analogRead(A7));

Which model "the micro" are you using?

i got this from other samples i found they all had that string inside the parentheses, but there is a 0 to 1023 right before it.
here is the link

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