Skip to content
Home > Components > Sensors > Analog Joystick

Analog Joystick

A thumb-operated two-axis joystick module with a built-in push button, ideal for controlling movement or navigating menus.

Component Preview

Analog JoystickAnalog Joystick

This module consists of two independent 10k potentiometers (one for the X-axis and one for the Y-axis) and a tactile push button for the Z-axis. It is electrically identical to the thumbsticks found on console game controllers.

SensorsAnalog InputHuman Interface

Overview

By measuring the resistance of the two potentiometers, a microcontroller can determine the exact position of the thumbstick across a 2D plane. When resting in the center, both the X and Y axes output exactly half of the supply voltage.

Pin Reference

PinTypeDescription
GNDpowerGround reference.
VCCpowerPower supply (usually 5V or 3.3V, matching your MCU's logic level).
VRx / HORZanalogX-axis output. Outputs an analog voltage based on horizontal position.
VRy / VERTanalogY-axis output. Outputs an analog voltage based on vertical position.
SW / SELdigitalSwitch output. Connects to GND when the joystick is pressed down.

Configurable Attributes

This component currently has no configurable attributes in the simulator. You can interact with it directly using your mouse.

Working Principle

  1. X and Y Axes: The VCC and GND pins apply a voltage across two 10kΩ potentiometers. Moving the stick turns the wipers, changing the voltage at the VRx and VRy pins from 0V (one extreme) to VCC (the opposite extreme). The center position outputs VCC / 2.
  2. Button (SW): The SW pin is a simple tactile switch that connects to GND when pressed. It requires an internal or external pull-up resistor to function correctly.

Wiring Diagram

  1. Connect VCC to 5V (or 3.3V) and GND to Ground.
  2. Connect VRx (HORZ) to an Analog Input pin (e.g., A0).
  3. Connect VRy (VERT) to another Analog Input pin (e.g., A1).
  4. Connect SW (SEL) to a Digital Input pin (e.g., 2).

Wiring Diagram

Example Arduino Code

cpp
const int xPin = A0; // VRx
const int yPin = A1; // VRy
const int swPin = 2; // SW

void setup() {
  // The switch connects to ground, so we MUST enable the internal pull-up resistor.
  pinMode(swPin, INPUT_PULLUP);
  Serial.begin(9600);
}

void loop() {
  int xVal = analogRead(xPin);
  int yVal = analogRead(yPin);
  
  // Note: Because of the pull-up, the switch reads LOW (0) when pressed!
  int swVal = digitalRead(swPin); 
  
  Serial.print("X: "); Serial.print(xVal);
  Serial.print(" | Y: "); Serial.print(yVal);
  
  if (swVal == LOW) {
    Serial.println(" | Button: PRESSED");
  } else {
    Serial.println(" | Button: Released");
  }
  
  delay(100);
}

Simulation Notes

  • In the simulator, click and drag the joystick head to move it.
  • To simulate pressing the button, click the center of the joystick without dragging.
  • The resting value of the analog pins in the simulator will be exactly 512 (on a 10-bit ADC). Real joysticks usually rest anywhere between 490 and 530, so you should always implement a "deadzone" in your code.

Released under the MIT License.