Skip to content

Input / Touch · Arduino Uno guide

Interfacing PS2-Style Analog Joystick Module with Arduino Uno

Two-axis analog input for controllers and pan-tilt rigs.

Updated November 14, 2026 Arduino C++None — built-in analogRead/digitalRead

Joystick Module practical reference

The PS2-style analog joystick module is a two-axis, spring-centered thumbstick built from two potentiometers — one for the X axis and one for the Y axis — plus a momentary push-button triggered by pressing straight down on the stick. It reports smooth analog positions on each axis rather than simple on/off directions, making it the standard input for robot controllers, pan-tilt camera rigs, and any project that needs proportional, joystick-style control.

Key specifications

  • Axes: 2-axis analog (X and Y), each driven by an independent 10kΩ potentiometer
  • Operating voltage: 3.3V–5V DC
  • Output type: Analog voltage per axis, proportional to stick position (read with analogRead())
  • Center position output: ~half of supply voltage (e.g. ~2.5V at 5V supply) when stick is at rest
  • Push-button: Momentary switch (SW pin), activated by pressing the stick down, active LOW
  • Interface: 2 analog pins (VRx, VRy) + 1 digital pin (SW)
  • Mechanical travel: Spring-loaded, self-centering in both axes

Pinout and connection notes

Each axis needs its own analogRead()-capable pin, and the SW button pin should be configured with INPUT_PULLUP since it pulls to GND when pressed. On 3.3V boards like the ESP32, the module still works fine at 3.3V supply, though the analog center-point and range will scale down accordingly.

  • GND: Ground
  • +5V: Power, 3.3–5V DC
  • VRx: X-axis analog output — connect to an analog input pin
  • VRy: Y-axis analog output — connect to an analog input pin
  • SW: Push-button output, active LOW — connect to a digital input pin with pull-up enabled

Integration checklist

  1. Confirm the exact part number and breakout-board revision.
  2. Verify supply voltage, current demand, logic levels, and signal direction against the datasheet.
  3. Check controller pin assignments and bus address or interface mode against the example code.
  4. Power up with external loads disconnected, then test signals before full integration.
  5. If readings or communication fail, check power and ground first, then pin mapping, interface settings, and library initialization.

Troubleshooting and reproducibility

Record the board used, wiring, library/version, supply arrangement, and measured behavior. Use the selected board-specific wiring example as the source of truth. Never assume visually similar modules share identical voltage tolerance or pin order.

Calibrating the joystick for a real controller

Do not assume the joystick rests at exactly half the ADC range. Read both axes at rest and calculate a centre value for each. Move the stick to each extreme and record the observed minimum and maximum. Use these measured endpoints to map the usable travel into the application's control range, and add a small dead zone around centre to prevent jitter. A dead zone that is too large makes fine control difficult, so tune it against actual hardware.

The push switch is mechanical and can bounce. Debounce it in software and distinguish a short press from a held press if the application needs both actions. On an ESP32, check the selected ADC pins and attenuation settings for the board variant; on an Arduino Uno, ADC readings are referenced to the analog supply and can shift if that supply changes.

If an axis is reversed, invert its mapped output in software rather than swapping power and ground. If readings jump, check common ground, connector solder joints, ADC input range, wiring length, and nearby motor or PWM noise. Keep the joystick powered from the voltage supported by its specific breakout and never let an analog output exceed the microcontroller's permitted ADC input voltage.

Wiring & code

Setting up Joystick Module with Arduino Uno

Library

None — built-in analogRead/digitalRead by —

No library needed; uses core Arduino functions only.

Wiring

Component pinArduino Uno pinNote
+5V5V
GNDGND
VRxA0
VRyA1
SWD2Press-to-click button, active LOW — use INPUT_PULLUP.
sketch.ino
#include <Arduino.h>
#define VRX A0
#define VRY A1
#define SW  2

void setup() {
  Serial.begin(9600);
  pinMode(SW, INPUT_PULLUP);
}

void loop() {
  int x = analogRead(VRX);
  int y = analogRead(VRY);
  bool pressed = !digitalRead(SW);

  Serial.print(F("X: ")); Serial.print(x);
  Serial.print(F("  Y: ")); Serial.print(y);
  Serial.print(F("  Pressed: ")); Serial.println(pressed);
  delay(100);
}
  • Centre position reads roughly 512 on both axes but varies module to module — calibrate at startup rather than hardcoding 512.
  • SW is a separate physical pushbutton triggered by pressing the stick down, unrelated to X/Y position.

Keep learning

Related guides & projects