Description
KY-023 Arduino joystick module, it uses a biaxial potentiometer to control the X and Y axis. When pushed down, it activates a switch. Based on the PS2 controller's joystick, it's used to control a wide range of projects from RC vehicles to color LEDs.
Specifications
The KY-023 Joystick module consists of two 10k potentiometers perpendicularly positioned to control the X and Y axis by changing the resistance when the joystick is moved. A push button is activated when the joystick is pushed down the Z axis.
Operating Voltage | 3.3V to 5V |
Board Dimensions | 2.6cm x 3.4cm [1.02in x 1.22in] |
Arduino KY-023 Connection Diagram
We'll use a couple of analog pins on the Arduino to read the values from the joystick's potentiometers and a digital pin to read values from the switch.
KY-023 | Arduino |
GND | GND |
+5V | 5V |
VRx | A0 |
VRy | A1 |
SW | 7 |

KY-023 Example Code
The following Arduino sketch will continually read values from the potentiometers and button on the KY-023. Moving the joystick up/down will increase/decrease the values of X and moving the joystick left/right will increase/decrease for values of Y. Push the joystick down to activate the button.
int value = 0;
void setup() {
//pinMode(A0, INPUT);
//pinMode(A1, INPUT);
pinMode(7, INPUT);
Serial.begin(9600);
}
void loop() {
value = analogRead(A0); // read X axis value [0..1023]
Serial.print("X:");
Serial.print(value, DEC);
value = analogRead(A1); // read Y axis value [0..1023]
Serial.print(" | Y:");
Serial.print(value, DEC);
value = digitalRead(7); // read Button state [0,1]
Serial.print(" | Button:");
Serial.println(value, DEC);
delay(100);
}
Setting analog pins as input (line 4 and 5) are not really necessary, the analogRead() function will automatically set the pins as analog input when used. Some people prefer to explicitly declare analog pins as input for the sake of readability.
Leave a Reply