KY-023 Dual Axis Joystick Module

View on Amazon
Overview
About KY-023 Dual Axis Joystick Module
The KY-023 Dual Axis Joystick Module is an input device that combines two potentiometers and a push-button switch, allowing for control in both the X and Y axes. Each axis corresponds to a potentiometer that outputs an analog voltage, which can be read by microcontrollers like the Arduino or ESP32. The module also features a push-button that activates when the joystick is pressed down. This joystick is commonly used in robotics, gaming, and other interactive projects.
Get Your KY-023
đĄ Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.
KY-023 Specifications
Complete technical specification details for KY-023 Dual Axis Joystick Module
đ Technical Parameters
KY-023 Pinout
The **KY-023** is a 5-pin dual-axis joystick module with integrated push button:
Visual Pinout Diagram

Pin Types
Quick Tips
**Interface**: Dual analog output + digital button,đšī¸ **Axes**: X and Y axis potentiometers (0-3.3V or 0-5V range)
**Button**: Built-in push-button (active low when pressed),⥠**Power**: 3.3V or 5V operation
**Center Position**: ~1.65V (3.3V) or ~2.5V (5V) when centered,đ¯ **Applications**: Game controllers, robotic navigation, camera control, RC vehicles
Pin Descriptions
| Pin Name | Type | Description | Notes |
|---|---|---|---|
1 GND | Power | Ground connection | |
2 +5V | Power | Power supply | 3.3V or 5V (check compatibility) |
3 VRx | Communication | X-axis analog output | Voltage varies with X position |
4 VRy | Communication | Y-axis analog output | Voltage varies with Y position |
5 SW | Control | Switch/button signal | Active low when pressed |
Wiring KY-023 to ESP32
To interface the **KY-023** with an **ESP32** for joystick input:
Visual Wiring Diagram

Connection Status
Protocol
Pin Connections
| KY-023 Pin | Connection | ESP32 Pin | Description |
|---|---|---|---|
1 GND Required | GND | Ground | |
2 +5V Required | 3.3V | Power supply (use 3.3V for ESP32) | |
3 VRx Required | GPIO36 | X-axis analog input (ADC pin) | |
4 VRy Required | GPIO39 | Y-axis analog input (ADC pin) | |
5 SW Optional | GPIO34 | Button input with internal pull-up |
**ADC Pins**: Use GPIO32-39 for analog inputs on ESP32
**Voltage**: Use 3.3V to match ESP32 ADC range (0-3.3V)
**Centering**: Read center position at startup for calibration
**Pull-up**: Enable internal pull-up resistor on SW pin
**Mapping**: Map ADC values (0-4095) to desired ranges
KY-023 Troubleshooting
Common issues and solutions to help you get your sensor working
Common Issues
Issue: No change in analog readings when moving the joystick.
Solutions:
- Verify all connections are secure and correctly placed.
- Ensure the module is receiving the appropriate voltage (3.3V or 5V).
- Check that the microcontroller's analog input pins are correctly configured.
- Test the joystick with a multimeter to confirm the potentiometers are functioning.
Issue: The push-button does not trigger any response.
Solutions:
- Ensure the SW pin is connected to a digital input configured with a pull-up resistor.
- Check for continuity in the button circuit using a multimeter.
- Confirm that the microcontroller's digital input pin is correctly configured in the code.
Debugging Tips
Use the Serial Monitor to check for error messages and verify the sensor's output. Add debug prints in your code to track the sensor's state.
Use a multimeter to verify voltage levels and check for continuity in your connections. Ensure the power supply is stable and within the sensor's requirements.
Additional Resources
KY-023 Programming Examples
Ready-to-use code examples for different platforms and frameworks
// Declaration and initialization of the input pins
int JoyStick_X = A0; // X-axis signal
int JoyStick_Y = A1; // Y-axis signal
int Button = 3; // Button
void setup() {
pinMode(JoyStick_X, INPUT);
pinMode(JoyStick_Y, INPUT);
pinMode(Button, INPUT_PULLUP); // Enable internal pull-up resistor
Serial.begin(9600); // Serial output with 9600 bps
}
void loop() {
float x, y;
int buttonState;
// Read current values and convert to voltage
x = analogRead(JoyStick_X) * (5.0 / 1023.0);
y = analogRead(JoyStick_Y) * (5.0 / 1023.0);
buttonState = digitalRead(Button);
// Output the values
Serial.print("X-axis:"); Serial.print(x, 4); Serial.print("V, ");
Serial.print("Y-axis:"); Serial.print(y, 4); Serial.print("V, ");
Serial.print("Button:");
if (buttonState == HIGH) {
Serial.println("not pressed");
} else {
Serial.println("pressed");
}
delay(200);
}This Arduino code reads the analog values from the X and Y axes of the KY-023 joystick and the digital state of the push-button. It then prints the corresponding voltage levels and button state to the serial monitor.
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/adc.h"
#include "driver/gpio.h"
#define JOYSTICK_X ADC1_CHANNEL_0 // GPIO36
#define JOYSTICK_Y ADC1_CHANNEL_3 // GPIO39
#define BUTTON GPIO_NUM_34
void app_main(void) {
adc1_config_width(ADC_WIDTH_BIT_12);
adc1_config_channel_atten(JOYSTICK_X, ADC_ATTEN_DB_11);
adc1_config_channel_atten(JOYSTICK_Y, ADC_ATTEN_DB_11);
gpio_set_direction(BUTTON, GPIO_MODE_INPUT);
gpio_pulldown_en(BUTTON);
printf("KY-023 Joystick Test\n");
while (1) {
int x_value = adc1_get_raw(JOYSTICK_X);
int y_value = adc1_get_raw(JOYSTICK_Y);
int button_state = gpio_get_level(BUTTON);
printf("X: %d, Y: %d, Button: %s\n", x_value, y_value, button_state ? "Not Pressed" : "Pressed");
vTaskDelay(pdMS_TO_TICKS(200));
}
}This ESP-IDF code reads analog values from the KY-023 joystick's X and Y axes using ADC1 on GPIO36 and GPIO39. It also monitors the push-button state on GPIO34 and prints the readings to the console every 200ms.
sensor:
- platform: adc
pin: GPIO36
name: "KY-023 Joystick X-Axis"
update_interval: 200ms
- platform: adc
pin: GPIO39
name: "KY-023 Joystick Y-Axis"
update_interval: 200ms
binary_sensor:
- platform: gpio
pin:
number: GPIO34
mode: INPUT_PULLUP
name: "KY-023 Joystick Button"This ESPHome configuration sets up the KY-023 joystick module on ESP32. It reads the X and Y-axis values as analog inputs and detects button presses on GPIO34, logging the results every 200ms.
platformio.ini
[env:esp32]
platform = espressif32
board = esp32dev
framework = arduinomain.cpp
#include <Arduino.h>
#define JOYSTICK_X A0
#define JOYSTICK_Y A1
#define BUTTON 3
void setup() {
pinMode(JOYSTICK_X, INPUT);
pinMode(JOYSTICK_Y, INPUT);
pinMode(BUTTON, INPUT_PULLUP);
Serial.begin(115200);
Serial.println("KY-023 Joystick Module Test");
}
void loop() {
int x_value = analogRead(JOYSTICK_X);
int y_value = analogRead(JOYSTICK_Y);
int button_state = digitalRead(BUTTON);
Serial.printf("X: %d, Y: %d, Button: %s\n", x_value, y_value, button_state ? "Not Pressed" : "Pressed");
delay(200);
}This PlatformIO code reads the analog values of the KY-023 joystick's X and Y axes and detects button presses. It prints the readings to the serial monitor every 200ms.
import machine
import time
JOYSTICK_X = machine.ADC(machine.Pin(36))
JOYSTICK_Y = machine.ADC(machine.Pin(39))
BUTTON = machine.Pin(34, machine.Pin.IN, machine.Pin.PULL_UP)
JOYSTICK_X.atten(machine.ADC.ATTN_11DB)
JOYSTICK_Y.atten(machine.ADC.ATTN_11DB)
while True:
x_value = JOYSTICK_X.read()
y_value = JOYSTICK_Y.read()
button_state = BUTTON.value()
print("X:", x_value, "Y:", y_value, "Button:", "Not Pressed" if button_state else "Pressed")
time.sleep(0.2)This MicroPython script reads the analog values of the KY-023 joystick's X and Y axes using ADC on GPIO36 and GPIO39. It also monitors button presses on GPIO34 and prints the results every 200ms.
Wrapping Up KY-023
The ESP32 KY-023 Dual Axis Joystick Module is a powerful KY-0xx module sensor that offers excellent performance and reliability. With support for multiple development platforms including Arduino, ESP-IDF, ESPHome, PlatformIO, and MicroPython, it's a versatile choice for your IoT projects.
Best Practices
For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.
Safety First
Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.
Ready to Start Building?
Now that you have all the information you need, it's time to integrate the KY-023 into your ESP32 project and bring your ideas to life!
Explore Alternative Sensors
Looking for alternatives to the KY-023? Check out these similar sensors that might fit your project needs.

KY-006 Passive Buzzer Module
The KY-006 is a passive piezoelectric buzzer module that produces sound when driven by a PWM signal. It is ideal for generating various...

KY-031 Knock Sensor Module
The KY-031 is a knock sensor module that detects physical impacts or vibrations. Upon detecting a knock, it outputs a digital signal, making...

KY-011 Two-Color LED Module
The KY-011 is a two-color LED module featuring a common cathode 3mm LED capable of emitting red and green light. By adjusting the intensity...





