HIBIIRO
How to Use a 2-Axis Analog Thumb Joystick Module with Arduino
Parts Used
- 1× Arduino Uno R3 (or compatible board)
- 1× 2-Axis Analog Thumb Joystick Module
- 5× Jumper Wires
Environment
Arduino IDE 2.3.4
Wiring Diagram
Connect the joystick’s VRx and VRy outputs to Arduino analog pins A0 and A1, and connect the push switch SW pin to digital pin D7. (Check our Interactive Arduino Uno Pinout Chart for reference.)

Arduino Sketch (No External Library Needed)
This sketch reads the X and Y potentiometers via analogRead() and prints coordinates to the Serial Monitor only when the stick moves beyond a small cumulative change threshold:
const int VRX = A0;
const int VRY = A1;
const int SW = 7;
const int threshold = 1;
bool is_first = true;
int xpos;
int ypos;
bool sw;
float previous_x;
float previous_y;
float cumulative_x = 0;
float cumulative_y = 0;
void setup() {
Serial.begin(9600);
pinMode(SW, INPUT_PULLUP);
}
void loop() {
xpos = analogRead(VRX);
ypos = analogRead(VRY);
sw = digitalRead(SW);
int xpos_change = xpos - previous_x;
int ypos_change = ypos - previous_y;
if (is_first) {
is_first = false;
} else {
// Update cumulative movement delta
cumulative_x += abs(xpos_change);
cumulative_y += abs(ypos_change);
if (cumulative_x > threshold || cumulative_y > threshold) {
Serial.print("X=");
Serial.print(xpos);
Serial.print(" Y=");
Serial.println(ypos);
cumulative_x = 0;
cumulative_y = 0;
} else if(!sw) {
; // Handle push-button click here (active LOW)
}
}
previous_x = xpos;
previous_y = ypos;
delay(100);
}Be sure to configure the switch pin with pinMode(SW, INPUT_PULLUP); in setup()—without the internal pull-up resistor enabled, the digital input floats and produces erratic false triggers.