ESP32 WROOM 32E and an Analog Joystick how to?

a_predicament
Posts: 1
Joined: Sat Apr 02, 2022 5:26 am

ESP32 WROOM 32E and an Analog Joystick how to?

Postby a_predicament » Sat Apr 02, 2022 11:47 pm

Hey so I have the ESP32 WROOM 32E and a standard 5 pin analog 2 axis joystick module and I would like to use them together but I am having issues. I am using the arduino IDE with ESP-idf installed. The issue is that with the following code the print to monitor values do no reflect the full range of motion that the joystick can make along 1 axis. When the joystick is half way between stationary and being pushed all the way the values are maxed out when they should be equal to the position it is at. Example, I want to be able to move the joystick in ten physical and equal increments and to have 10 equal increments in value returned from the joystick. If the joystick axis has 90 degrees of motion and 45degrees are on each side of the +/- then only 22.5 degrees on each side is currently being read by the ESP32 and it evaluates to that point making every location along the axis above it or below it maxed. It is not a hardware problem, it is not a device problem I have tried multiple of each and it is not a wiring or cable issue. I was not able to follow the ADC pages in the documentation to make any improvements but I am welcome to advice.

Code: Select all

int test  = 0;
const int pinVar  = 33;

int  read_jstick(int rxy)
{ int JXY = analogRead(rxy);
  return JXY;
} 
void  print_jstick(int pjs)
{ Serial.print("Joystick-X:  "); Serial.println(pjs);
}
void setup() 
{ Serial.begin(115200); pinMode(pinVar,OUTPUT);
} 
void loop() 
{ test = read_jstick(pinVar);
  print_jstick(test);
}

Who is online

Users browsing this forum: amiral and 61 guests