0

Mini 2-axis analog thumbstick doesn't act as an analog stick
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Mini 2-axis analog thumbstick doesn't act as an analog stick

by progamateur on Sat May 25, 2019 3:49 pm

Hello, everyone.
I'm starting out in everything to do with Arduino. Following this nice tutorial, I bought the Mini 2-Axis Analog Thumbstick as well as the Analog Mini Thumbstick Breakout Board to use it as an analog joystick. After buying an Arduino Leonardo Pro Mini and uploading this code (see "USB Mouse Functionality"), I was able to get the Thumbstick working.
Unfortunately, the sensitivity of the movements does not seem analogical, it is almost at all or nothing.
There are a very few changes when I change the "sensitivity" parameter but we are very far from an analog joystick.

Would you know a more reliable code or how to fix it, please? Thank you very much.

progamateur
 
Posts: 5
Joined: Sat May 25, 2019 3:34 pm

Re: Mini 2-axis analog thumbstick doesn't act as an analog s

by adafruit_support_bill on Sat May 25, 2019 3:58 pm

Looks like the mouse code takes values in the range of +/-0 127. The raw joystick readings on the Leonardo will be in the range of +/- 512. With a sensitivity divisor of 2, you will be maxed out at half scale. So you will probably get a better action using a sensitivity of 4.

adafruit_support_bill
 
Posts: 73051
Joined: Sat Feb 07, 2009 10:11 am

Re: Mini 2-axis analog thumbstick doesn't act as an analog s

by progamateur on Sun May 26, 2019 3:23 pm

Thank you very much for helping me. Unfortunately, with a sensitivity of 4, the pointer jumps from one corner to another without having a slow progression.
I have tried sensitivity of 4, 150, 250, 350, 450. There is no analog behavior at all.

There is a real problem, either the code doesn't work with this product (that's what I think), or the product is defective (I doubt it).

For example:
- if I do "UP", the mouse goes much faster than "DOWN",
- and if I press "DOWN" gently the mouse goes faster than if I press "DOWN" hard.

Isn't there a more reliable code to try, please?

Thank you very much.

progamateur
 
Posts: 5
Joined: Sat May 25, 2019 3:34 pm

Re: Mini 2-axis analog thumbstick doesn't act as an analog s

by adafruit_support_bill on Sun May 26, 2019 3:35 pm

Try printing out the raw analog values from the joystick so we know what the range of readings you are getting via the Pro Mini

adafruit_support_bill
 
Posts: 73051
Joined: Sat Feb 07, 2009 10:11 am

Re: Mini 2-axis analog thumbstick doesn't act as an analog s

by progamateur on Wed Jun 05, 2019 1:47 pm

Hello, so I could find a code that works well in terms of input. However, my thumbstick is not recognized as a classic controller (for instance, if I go into Windows 10 > Controll Panel > Devices and printers, I can see "Arduino" but I can't test the analog pad input as I can do with any controller). What I mean is that I can't see such page :
Image

QUESTION :
It seems that the thumbstick is not considered as a game controller (driver issue ?), so is there anything missing ? Please find below the code :


Code: Select all | TOGGLE FULL SIZE
// Arduino pin numbers
const int SW_pin = 2; // digital pin connected to switch output
const int X_pin = A0; // analog pin connected to X output
const int Y_pin = A1; // analog pin connected to Y output

void setup() {
  pinMode(SW_pin, INPUT);
  digitalWrite(SW_pin, HIGH);
  Serial.begin(115200);
}

void loop() {
  Serial.print("Switch:  ");
  Serial.print(digitalRead(SW_pin));
  Serial.print("\n");
  Serial.print("X-axis: ");
  Serial.print(analogRead(X_pin));
  Serial.print("\n");
  Serial.print("Y-axis: ");
  Serial.println(analogRead(Y_pin));
  Serial.print("\n\n");
  delay(500);
}



Thank you !

progamateur
 
Posts: 5
Joined: Sat May 25, 2019 3:34 pm

Re: Mini 2-axis analog thumbstick doesn't act as an analog s

by adafruit_support_bill on Wed Jun 05, 2019 2:24 pm

By default, your Arduino Pro Mini is going to look like an Arduino Pro Mini to your computer. If you want to emulate an controller device, you need to program it to do so:

https://www.tinkerboy.xyz/how-to-progra ... h-arduino/

adafruit_support_bill
 
Posts: 73051
Joined: Sat Feb 07, 2009 10:11 am

Re: Mini 2-axis analog thumbstick doesn't act as an analog s

by progamateur on Wed Jun 05, 2019 4:15 pm

Thank you very much, my Leonardo Pro Micro is now recognized as a gamepad controller.
However, I am still not able to setup the analog Thumbstick (the Gamepad setup shows a centered cursor while I am moving the thumbstick, and the serial monitor does not show anything).

I am not a programmer, but reading the Leonardo code, I guess something shall be enabled (push a button or something else) to make the pad operating, but as the thumbstick does not have any button...

So we have 2 things :
Code: Select all | TOGGLE FULL SIZE
1. a previous code (see my previous post) that works but the Leonardo Pro Micro is not recognized as a gamepad

2. a code with makes the Leonardo Pro mini recognized as a gamepad but the analog thumbstick is not recognized itself


I am sure we can solve this challenge !
Please, do you know how to "inject" the Thumbstick working code into the Leonardo gamepad script ?

Thank you so much for your kind help.

progamateur
 
Posts: 5
Joined: Sat May 25, 2019 3:34 pm

Re: Mini 2-axis analog thumbstick doesn't act as an analog s

by adafruit_support_bill on Wed Jun 05, 2019 4:24 pm

I'm not familiar with the library being used, but it looks like you need to change this line
Code: Select all | TOGGLE FULL SIZE
#define ENABLE_ANALOG1 false

to this:
Code: Select all | TOGGLE FULL SIZE
#define ENABLE_ANALOG1 true

or it will not read the analog inputs.

adafruit_support_bill
 
Posts: 73051
Joined: Sat Feb 07, 2009 10:11 am

Re: Mini 2-axis analog thumbstick doesn't act as an analog s

by progamateur on Fri Jun 07, 2019 8:39 pm

Perfect ! It works, thank you so much for your help, we finally could solve this issue.
Thank you again

progamateur
 
Posts: 5
Joined: Sat May 25, 2019 3:34 pm

Re: Mini 2-axis analog thumbstick doesn't act as an analog s

by adafruit_support_bill on Sat Jun 08, 2019 5:35 am

Good to hear. Thanks for the follow-up.

adafruit_support_bill
 
Posts: 73051
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.