Yet another topic about Joystick poor range and Arduino Analog reading

Hello,

I am trying to control a remote car with arduino and nrf240l01 and RadioHead library - nothing fancy so far.
For now I have a joystick with X and Y axes, it is connected to my Arduino Nano "client" which sends the values of X and Y to my Arduino Nano "server" which displays the values on the Serial Monitor.
The client read properly the values from 0 to 1023 for both axes (with ~520 at center). But the DeadZone is really huge. from the central position to up or bottom (or left/right) I have like 10% of the range that until it goes to 0 or 1023. As a result I very very quickly reach 1023 or 0, and cannot easily manage the speed of my motor.

The joystick looks like the one used in this tutorial:

Question: Do you know if there is a way to be able to use a wider range of joystick position by tweaking the code?

for now I have something very simple:

Client:

[...]

int xSensorPin = 0;
int ySensorPin = 1;

void loop() {
    int xSensorValue = analogRead(xSensorPin);
    delay(100);
    int ySensorValue = analogRead(ySensorPin);
    data.xSensorValue = xSensorValue;
    data.ySensorValue = ySensorValue;
    nrf24.send((uint8_t*)&data, sizeof(data));
    nrf24.waitPacketSent();
}

Server

[...]

void loop(){
    if (nrf24.available()){
        struct Data *data;
        uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];
        uint8_t len = sizeof(buf);
        if (nrf24.recv(buf, &len)){
            data = (struct Data *)buf;
            Serial.print("X:");
            Serial.println(data->xSensorValue);
            Serial.print("Y:");
            Serial.println(data->ySensorValue);
            delay(600);
        }
    }
}

Thank you.

Hi again, I figured out that I might not have been explicit enough so here is a picture relating my issue
the full range of the stick is blue+green part, but values are varying only within the blue area, leaving a lot of dead zone(?) - green part where the values are either 0 or 1023 (depending on side)

I am right to say that it is fault of the potentiometer that might have too big resistance passed the blue area? Do you maybe know so other joystick that can use more range area?

Thanks.


edit: on the image is written 1024, but should be 1023 sorry.

1 Like

Are there no adjustments on the joystick? Can you post a link or brand name and part #?

So if you connect one pot to 5volt/A0/GND (assuming you use a 5volt Arduino), then you get 0-1023 on the serial monitor with a small angle of the joystick when you use the simple sketch below.
I would expect the opposite. A small range of values with a large movement of the stick.
Leo..

const byte xSensorPin = A0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println(analogRead(xSensorPin));
  delay(250);
}

outsider:
Are there no adjustments on the joystick? Can you post a link or brand name and part #?

There are no serial nor brand, its some cheap Chinese piece that I bought on ebay. All I have is some number on potentiometer: 103 / 267. there is also no adjustment possible.

Wawa:
So if you connect one pot to 5volt/A0/GND (assuming you use a 5volt Arduino), then you get 0-1023 on the serial monitor with a small angle of the joystick when you use the simple sketch below.
I would expect the opposite. A small range of values with a large movement of the stick.
Leo..

Yes I reach 1023 or 0 very quickly like shown on the picture, just a tiny push and I reach the min/max.

The joystick is the same as this one:

naitsab:
Yes I reach 1023 or 0 very quickly like shown on the picture, just a tiny push and I reach the min/max.

If you have used the code I provided, and it reaches 0 and 1023 with a small movement, then it can't be fixed.
Buy a better joystick.
Leo..

Wawa:
If you have used the code I provided, and it reaches 0 and 1023 with a small movement, then it can't be fixed.
Buy a better joystick.
Leo..

Thanks that is what I thought. Would you be able to recommended a similar joystick with a full working range by chance ?

I am trying to do the exact same thing and my car's steering is suffering from the same symptoms the cheap joy stick that came included with my ELEGOO kit.

If anyone has any recommendations let us know!

My alternative at this point is to buy a used car RC remote transmitter and gut out the electronics so I can have a more sensitive wheel and throttle control.

Hi!

I had the same issue. I think it is because it is a 10kohm resistor and it kills the 5v too quickly. Im no expert but that is my theory.

i got a broken Xbox 360 controller and took the thumb stick from it and it works great.