

The KY-020 is a simple analog joystick module designed for two-dimensional control. Manufactured by Arduino, this module features two potentiometers that detect the position of the joystick along the X and Y axes. The output is provided as variable voltage signals, which can be easily read by microcontrollers such as the Arduino UNO. Additionally, the module includes a push-button switch that activates when the joystick is pressed down.








The KY-020 joystick module has the following key specifications:
| Parameter | Value |
|---|---|
| Manufacturer | Arduino |
| Part ID | KY-020 |
| Operating Voltage | 3.3V - 5V |
| Output Type | Analog (X and Y axes), Digital (SW) |
| X-Axis Resistance | 10 kΩ |
| Y-Axis Resistance | 10 kΩ |
| Push-Button Type | Normally Open (NO) |
| Dimensions | 34mm x 26mm x 32mm |
The KY-020 module has 5 pins, as described in the table below:
| Pin | Name | Description |
|---|---|---|
| 1 | GND | Ground connection for the module. |
| 2 | +5V | Power supply input (3.3V to 5V). |
| 3 | VRx | Analog output for the X-axis position. |
| 4 | VRy | Analog output for the Y-axis position. |
| 5 | SW | Digital output for the push-button (LOW when pressed, HIGH when released). |
+5V pin to the 5V output of your microcontroller and the GND pin to ground.VRx and VRy pins to analog input pins on your microcontroller to read the joystick's position.SW pin to a digital input pin to detect when the joystick is pressed.SW pin and +5V.Below is an example Arduino sketch to read the joystick's X and Y positions and detect button presses:
// Define pin connections
const int VRxPin = A0; // X-axis analog output connected to A0
const int VRyPin = A1; // Y-axis analog output connected to A1
const int SWPin = 2; // Push-button digital output connected to D2
void setup() {
// Initialize serial communication for debugging
Serial.begin(9600);
// Configure the SW pin as input with an internal pull-up resistor
pinMode(SWPin, INPUT_PULLUP);
}
void loop() {
// Read the X and Y axis values (0 to 1023)
int xValue = analogRead(VRxPin);
int yValue = analogRead(VRyPin);
// Read the state of the push-button (LOW when pressed)
bool buttonPressed = !digitalRead(SWPin);
// Print the joystick values to the Serial Monitor
Serial.print("X: ");
Serial.print(xValue);
Serial.print(" | Y: ");
Serial.print(yValue);
Serial.print(" | Button: ");
Serial.println(buttonPressed ? "Pressed" : "Released");
// Add a small delay for stability
delay(100);
}
No Output from the Module
Inconsistent Analog Readings
Push-Button Not Detected
Joystick Center Position Not Zero
Q1: Can the KY-020 be used with 3.3V microcontrollers like the ESP32?
A1: Yes, the KY-020 operates at 3.3V to 5V, making it compatible with 3.3V microcontrollers.
Q2: How do I increase the precision of the joystick readings?
A2: Use the microcontroller's ADC with higher resolution (e.g., 12-bit ADC) if available, and implement software filtering.
Q3: Can I use the KY-020 for 3D control?
A3: No, the KY-020 only supports two-dimensional control (X and Y axes). For 3D control, consider a joystick with an additional Z-axis.