Ir directamente al contenido

All items ship from our office in Colorado USA - $5.95 Flat-Rate US shipping & free shipping on orders over $75!

KY-023 Dual Axis XY Game Joystick Sensor Module Controller User Guide

KY-023 Dual Axis XY Game Joystick Sensor Module Controller User Guide

The KY-023 Dual Axis XY Joystick Module is an analog input device that provides proportional X and Y axis readings plus a digital push-button switch. Designed for Arduino, ESP32, AVR, PIC, and other microcontrollers, it's an excellent control interface for robotics, remote control systems, game controllers, camera gimbals, menu navigation, and any project that needs intuitive 2D directional input.

This guide covers how the module works, wiring, Arduino code, calibration, and troubleshooting — even if you're new to analog inputs.


⭐ Key Features

  • Dual-axis analog output: Two 10KΩ potentiometers provide smooth, proportional X and Y axis readings (0V–5V range, ~2.5V at center).
  • Integrated push-button switch: Press the joystick down for a digital input — perfect for mode switching, menu selection, or action triggers. Pulls to ground when pressed.
  • Self-centering: Spring-loaded mechanism returns the stick to center position when released.
  • 3.3V and 5V compatible: Works with both 3.3V and 5V microcontrollers (5V recommended for full analog range).
  • Simple 5-pin interface: Clearly labeled VCC, GND, VRx, VRy, and SW pins — connect directly to your microcontroller with jumper wires.
  • No libraries needed: Uses standard analogRead() and digitalRead() functions — works immediately with basic Arduino code.
  • Compact design: Just 34mm × 26mm × 32mm — fits easily on breadboards and inside project enclosures.

💡 How the KY-023 Joystick Module Works

The joystick module contains two 10KΩ potentiometers mounted at 90° to each other, connected to a thumb-stick via a gimbal mechanism. Each potentiometer acts as a voltage divider between VCC and GND:

  • Center position: Both VRx and VRy output approximately VCC/2 (~2.5V at 5V supply, analog reading ~512 on Arduino's 10-bit ADC).
  • Full left / full down: Output drops toward 0V (analog reading ~0).
  • Full right / full up: Output rises toward VCC (analog reading ~1023 at 5V).
  • Button press: Pressing the stick straight down closes the SW switch, pulling the pin to GND (reads LOW when a pull-up resistor is enabled).

The movement is fully proportional — the further you push the stick, the higher or lower the voltage. This allows for smooth, variable-speed control rather than simple on/off directional input.

Orientation

Important: For correct X-Y orientation (X-axis horizontal, Y-axis vertical), mount the module with the pins facing to the left. If your axes appear swapped or inverted, you can either rotate the module or swap/invert the axis readings in your code.


📋 Specifications

Parameter Value
Model KY-023
Axes X and Y (analog output)
Switch Push-button (digital, active LOW)
Operating Voltage 3.3V – 5V DC
Potentiometer Type 10KΩ ±20%, linear taper
Analog Output Range 0V to VCC (proportional to stick position)
Center Output ~VCC/2 (~2.5V at 5V supply, ~1.65V at 3.3V supply)
Arduino ADC Range 0–1023 (10-bit); center ≈ 512
ESP32 ADC Range 0–4095 (12-bit); center ≈ 2048
Switch Activation Pulls to ground when pressed (requires pull-up resistor)
Interface 5-pin header (VCC, GND, VRx, VRy, SW)
Dimensions 34 × 26 × 32mm (1.3" × 1.0" × 1.3")

📌 Pinout and Connection

The KY-023 module has a 5-pin header with the following connections:

Pin Label Connect To Description
1 VCC Arduino 5V (or 3.3V) Positive supply voltage. 5V recommended for full analog range.
2 GND Arduino GND Ground. Connect to the GND pin on your microcontroller.
3 VRx Analog pin (e.g., A0) Analog output for the X-axis. Voltage varies from 0V to VCC based on horizontal stick position.
4 VRy Analog pin (e.g., A1) Analog output for the Y-axis. Voltage varies from 0V to VCC based on vertical stick position.
5 SW Digital pin (e.g., D2) Push-button switch output. Normally HIGH (with pull-up), pulled LOW when pressed. Requires an internal or external pull-up resistor.

Example Wiring (Arduino Uno)

KY-023 Pin Arduino Pin
VCC 5V
GND GND
VRx A0
VRy A1
SW D2

Important: Since the switch pin (SW) pulls to ground when pressed, you must enable the internal pull-up resistor on the Arduino pin in your code (using INPUT_PULLUP), or add an external 10KΩ pull-up resistor between the SW pin and VCC.


💻 Arduino Example Code

const int joystickXPin = A0;    // X-axis analog input pin
const int joystickYPin = A1;    // Y-axis analog input pin
const int switchPin = 2;        // Switch digital input pin

int xValue = 0;                 // Variable to store the X-axis value
int yValue = 0;                 // Variable to store the Y-axis value
int switchState = 0;            // Variable to store the switch state

void setup() {
  Serial.begin(9600);           // Initialize serial communication
  pinMode(switchPin, INPUT_PULLUP); // Enable internal pull-up resistor
}

void loop() {
  // Read the analog values from the joystick
  xValue = analogRead(joystickXPin);
  yValue = analogRead(joystickYPin);

  // Read the digital value from the switch
  switchState = digitalRead(switchPin);

  // Print the values to the serial monitor
  Serial.print("X: ");
  Serial.print(xValue);
  Serial.print(", Y: ");
  Serial.print(yValue);
  Serial.print(", Switch: ");
  Serial.println(switchState);

  delay(100);                   // Delay for 100 milliseconds
}

What the Code Does

  • const int joystickXPin = A0; — Defines the analog pin connected to the X-axis output.
  • const int joystickYPin = A1; — Defines the analog pin connected to the Y-axis output.
  • const int switchPin = 2; — Defines the digital pin connected to the switch output.
  • pinMode(switchPin, INPUT_PULLUP); — Configures the switch pin as an input and enables the internal pull-up resistor. The pin reads HIGH when the button is not pressed, and LOW when pressed.
  • analogRead(joystickXPin); — Reads the analog value from the X-axis pin (range: 0–1023 on Arduino's 10-bit ADC).
  • analogRead(joystickYPin); — Reads the analog value from the Y-axis pin (range: 0–1023).
  • digitalRead(switchPin); — Reads the digital value from the switch pin (HIGH = not pressed, LOW = pressed).
  • Serial.print(...); — Prints the values to the Serial Monitor for debugging and observation.

Expected Serial Monitor Output

With the joystick at center and button not pressed:

X: 512, Y: 512, Switch: 1

With the joystick pushed fully right and up, button pressed:

X: 1023, Y: 0, Switch: 0

Note: Your center values may not be exactly 512 — this is normal. See the Calibration section below for how to handle this.


🔧 Calibration and Usage Tips

  • Centering: The joystick may not be perfectly centered at rest. Compensate in your code by reading the resting X and Y values at startup and subtracting them as an offset. Example:
    int xCenter = analogRead(joystickXPin);  // Read at startup
    int yCenter = analogRead(joystickYPin);
    // Then in loop:
    int xAdjusted = xValue - xCenter;  // -512 to +511 range
    int yAdjusted = yValue - yCenter;
  • Dead zones: Implement a dead zone around center to ignore small jitter and prevent unintended movement. Example:
    int deadZone = 30;  // Adjust this threshold as needed
    if (abs(xAdjusted) < deadZone) xAdjusted = 0;
    if (abs(yAdjusted) < deadZone) yAdjusted = 0;
  • Value mapping: The raw analog readings range from 0 to 1023. Use Arduino's map() function to convert to a more useful range:
    int speed = map(xValue, 0, 1023, -255, 255);  // For motor PWM
    int angle = map(yValue, 0, 1023, 0, 180);      // For servo control
  • Switch debouncing: If you experience erratic behavior from the switch, implement a software debounce. A simple approach:
    unsigned long lastDebounce = 0;
    int lastState = HIGH;
    int debounceDelay = 50;  // milliseconds
    
    int reading = digitalRead(switchPin);
    if (reading != lastState) {
      lastDebounce = millis();
    }
    if ((millis() - lastDebounce) > debounceDelay) {
      switchState = reading;  // Stable reading
    }
    lastState = reading;

🔌 Compatibility Notes

Arduino (Uno, Mega, Nano, Leonardo)

Full compatibility. Use 5V supply for maximum analog range. ADC is 10-bit (0–1023). This is the simplest and most common setup.

ESP32 / ESP8266

  • Use 3.3V supply — the ESP32's GPIO pins are not 5V tolerant.
  • The ESP32 ADC is 12-bit (0–4095), so center will be approximately 2048 instead of 512.
  • ESP32 ADC can be nonlinear at the extremes. For best results, use the ESP32's built-in ADC calibration or apply a lookup table correction.
  • ESP8266 has only one analog input (A0), so you can only read one axis without an external multiplexer or ADC.

Raspberry Pi

  • The Raspberry Pi has no built-in analog inputs. You will need an external ADC module (such as an ADS1115 or MCP3008) to read the VRx and VRy outputs.
  • The SW (switch) pin can be connected directly to a GPIO pin with an internal pull-up enabled.

STM32, AVR, PIC

Compatible with any microcontroller that has at least 2 analog input pins and 1 digital input pin. Match the supply voltage to your microcontroller's logic level (3.3V or 5V).


🛠️ Troubleshooting

Problem Possible Cause Solution
No readings (all zeros) Module not powered or wiring error Double-check VCC and GND connections. Verify the module is receiving 3.3V or 5V.
Erratic / noisy readings Loose ground connection or electrical noise Ensure all ground connections are secure. Add a 0.1µF ceramic capacitor between VCC and GND on the module to filter noise.
Switch not responding Pull-up resistor not enabled Enable the internal pull-up in your code (INPUT_PULLUP) or add an external 10KΩ pull-up resistor between SW and VCC.
Switch triggers randomly Mechanical switch bounce Implement software debouncing (see Calibration section above).
Values not centered at 512 Normal manufacturing variation Read the resting values at startup and use them as your center offset. See Calibration section.
X and Y axes are swapped Module orientation incorrect Rotate the module so the pins face to the left, or swap the VRx and VRy pin assignments in your code.
Axis direction is inverted Module orientation or potentiometer wiring Invert the reading in code: xValue = 1023 - analogRead(joystickXPin);
Readings max out at ~3.3V on ESP32 Using 5V supply on a 3.3V board Use 3.3V supply for ESP32. The analog range will be 0–3.3V, which is correct for the ESP32's ADC.
Only one axis works on ESP8266 ESP8266 has only one analog input (A0) Use an external ADC (ADS1115 or MCP3008) or multiplex the analog inputs.

🎯 Applications

  • Robotics control: Drive motors proportionally for smooth robot movement, control robotic arms and grippers.
  • RC vehicles and drones: Build custom transmitters with proportional throttle and steering.
  • Game controllers: Create custom game pads for PC, retro gaming, or arcade cabinets.
  • Camera pan/tilt: Control servo-driven camera gimbals and pan-tilt mechanisms.
  • Menu navigation: Scroll through menus on OLED/LCD displays with intuitive stick control.
  • IoT and home automation: Manual override control for smart home devices.
  • STEM education: Teach analog input, voltage dividers, and human-machine interfaces.

⚠️ Important Notes & Safety

  • Always disconnect power before making any wiring changes.
  • Operating voltage: 3.3V to 5V DC. Do not exceed 5V.
  • The SW pin requires a pull-up resistor (internal or external) to function correctly.
  • Avoid exposing the module to excessive moisture or extreme temperatures.
  • The potentiometers are mechanical components — avoid forcing the joystick beyond its natural range of motion.
  • For ESP32 and other 3.3V boards, use 3.3V supply only — do not connect 5V to 3.3V-logic GPIO pins.
  • This module is designed for hobby, educational, and prototyping use. It is not rated for industrial or safety-critical applications.

🛒 Where to Buy

You can purchase the KY-023 Dual Axis XY Joystick Module directly from Envistia Mall:


📚 Additional Resources



This guide is provided by Envistia Mall for educational and technical reference purposes. The manufacturer and Envistia LLC (dba Envistia Mall) are not responsible for any damages or losses resulting from the use of this product. Always follow proper electrical safety practices when working with electronic components. Specifications and features are based on manufacturer data and may vary between production batches.

Share this guide:
in

🛒 Related Products

Find the components mentioned in this guide in our store.

Browse Products →