Hey! starting my journy on Arduinio.When i tried to connect my joystick, and read the values from it,I gaet the whole range on X.
My problem is with Y: Resting pposition indicates 0, and if i move the joystick down it shows the value 512. if I move it upwards, the value does not change.
where is my problem? adding 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);
My problem is with Y: Resting pposition indicates 0, and if i move the joystick down it shows the value 512. if I move it upwards, the value does not change.
where is my problem? adding 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);
Last edited by a moderator: