This project will show you how to connect a Grove Thumb Joystick to your Arduino so that you can use it for any project where you’ll need some joystick control.
void setup() { Serial.begin(9600);
}
void loop() {
int sensorValue1 = analogRead(A0);
int sensorValue2 = analogRead(A1);
Serial.print("The X and Y coordinate is:");
Serial.print(sensorValue1, DEC);
Serial.print(",");
Serial.println(sensorValue2, DEC);
Serial.println(" ");
delay(200);
}
You should now see the X and Y values change as you move the Grove joystick.
Now that you have the basic set-up up and running you can easily incorporate the X and Y values received by the Arduino to any project where you need control. Simply use the variables sensorValue1 and sensorValue2 in your code.
From a quick tap to smashing that love button and show how much you enjoyed this project.