Hi, i´m using this Joystick Module Joystick Module with Push Button for Arduino
I wrote a code wich is similar to everyone i have found on the internet, but for some reason i only get values between 1018 and 1023 and 1022 when the potentiometers are in the middle.
my code:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.print("X axis:");
Serial.print(analogRead(0)); //print the analog value of the X axis
delay(100);
Serial.print(" Y axis:");
Serial.println(analogRead(1)); //print the analog value of the Y axis
delay(100);
}
This are some of the values that i get straight from the serial monitor.
X axis:1022 Y axis:1022
X axis:1022 Y axis:1022
X axis:1022 Y axis:1022
X axis:1022 Y axis:1022
X axis:1022 Y axis:1021
X axis:1022 Y axis:1022
X axis:1022 Y axis:1022
X axis:1022 Y axis:1022
X axis:1021 Y axis:1022
X axis:1022 Y axis:1022
X axis:1022 Y axis:1022
X axis:1021 Y axis:1022
X axis:1022 Y axis:1022
X axis:1022 Y axis:1022
X axis:1022 Y axis:1022
X axis:1022 Y axis:1022
X axis:1022 Y axis:1022
X axis:1022 Y axis:1022
X axis:1022 Y axis:1022
X axis:1022 Y axis:1022
X axis:1022 Y axis:1022
X axis:1021 Y axis:1022
X axis:1021 Y axis:1021
X axis:1021 Y axis:1022
X axis:1022 Y axis:1021
X axis:1021 Y axis:1021
X axis:1018 Y axis:1021
X axis:1018 Y axis:1021
X axis:1018 Y axis:1020
X axis:1018 Y axis:1021
X axis:1018 Y axis:1019
X axis:1018 Y axis:1017
X axis:1020 Y axis:1017
X axis:1020 Y axis:1017
X axis:1020 Y axis:1018
X axis:1020 Y axis:1017
X axis:1022 Y axis:1017
X axis:1023 Y axis:1018
X axis:1023 Y axis:1020
X axis:1023 Y axis:1020
X axis:1023 Y axis:1021
X axis:1023 Y axis:1023
X axis:1018 Y axis:1023
X axis:1017 Y axis:1023
X axis:1010 Y axis:1020
X axis:1003 Y axis:1020
X axis:997 Y axis:1022
X axis:999 Y axis:1023
X axis:999 Y axis:1023
X axis:1007 Y axis:1023
X axis:1006 Y axis:1023
X axis:1015 Y axis:1023
X axis:1015 Y axis:1023
X axis:1014 Y axis:1020
X axis:1013 Y axis:1016
X axis:1014 Y axis:1015
X axis:1016 Y axis:1020
X axis:1007 Y axis:1020
X axis:1002 Y axis:1020
X axis:1000 Y axis:1023
X axis:999 Y axis:1023
X axis:997 Y axis:1023
X axis:996 Y axis:1023
X axis:995 Y axis:1023
X axis:996 Y axis:1023
X axis:997 Y axis:1020
X axis:994 Y axis:1015
X axis:994 Y axis:1015
X axis:993 Y axis:1015
X axis:1012 Y axis:1015
X axis:1011 Y axis:1017
X axis:1012 Y axis:1021
X axis:1007 Y axis:1023
As you can see the Y axis goes between 1015 and 1023, with the centre in 1022.
The X axis on the other hand goes completly mad. It starts with 1022 being in the centre and going between 1018 and 1023, but after some rotations it ends up going down to 995. After some time it seems to get back to (1020-1023).
I´ve checked the conections by changing the pins and the wires, but it doesn´t seem to work.
I have also tried to assign bigger values with the 0 in the centre by changing the value to ((analog read(0)-1022)*100). but that just gives me the values -200, -100, 0 and 100. Nothing in the middle, so i guess the potentiometers aren´t that precise.
Thank you for reading and to anyone who can help.
