Hey, my joystick does not return the right values.
at first the values of the X axis were right, but the Y started at resting position 0 (instead of 512). The rangr og Y was0-512. not even less then 0.
tried to calibrate it' and now the whole joystick returns odd values(both X and Y).
any ideas?
(in my joystick, the X is connected to A2 and Y to A1)
thats my code:
int xpin = A2;
int ypin = A1;
int xval;
int yval=512;
void setup() {
Serial.begin(9600);
pinMode(xpin , INPUT);
pinMode(ypin , OUTPUT);
}
void loop() {
xval=analogRead(xpin);
yval = analogRead(ypin);
delay(200);
Serial.print("X: ");
Serial.print(xval);
Serial.print(" y: ");
Serial.println(yval);
}
i using the calibration from here: