The KY-023 Dual Axis Joystick Module is an input device that translates the user's physical movement into electronic signals. It is commonly used in electronic projects for controlling motors, servos, and other devices, providing an intuitive interface for two-dimensional control. The joystick module includes two potentiometers for the X and Y axes, which output analog signals corresponding to the position of the stick.
Pin | Description |
---|---|
GND | Ground |
+5V | Power supply (3.3-5V) |
VRx | X-axis analog output |
VRy | Y-axis analog output |
SW | Switch button output |
+5V
pin to the 5V output on your microcontroller (e.g., Arduino UNO).GND
pin to a ground pin on your microcontroller.VRx
pin to an analog input pin on your microcontroller to read the X-axis position.VRy
pin to another analog input pin to read the Y-axis position.SW
pin to a digital input pin if you wish to use the built-in switch.// KY-023 Dual Axis Joystick Module example for Arduino UNO
const int xAxisPin = A0; // Analog input pin for X-axis
const int yAxisPin = A1; // Analog input pin for Y-axis
const int buttonPin = 2; // Digital input pin for the button
void setup() {
pinMode(buttonPin, INPUT_PULLUP); // Initialize button pin as input with pull-up
Serial.begin(9600); // Start serial communication at 9600 baud
}
void loop() {
int xPosition = analogRead(xAxisPin); // Read the X-axis position
int yPosition = analogRead(yAxisPin); // Read the Y-axis position
int buttonState = digitalRead(buttonPin); // Read the button state
// Print the X and Y positions and button state to the serial monitor
Serial.print("X: ");
Serial.print(xPosition);
Serial.print(" | Y: ");
Serial.print(yPosition);
Serial.print(" | Button: ");
Serial.println(buttonState);
delay(100); // Delay for a short period to reduce serial output rate
}
analogReference()
function in Arduino if you are using a reference voltage other than the default 5V.Q: Can I use the KY-023 module with a 3.3V system? A: Yes, the module can operate at 3.3V, but the analog output range will be 0-3.3V instead of 0-5V.
Q: How can I increase the precision of the joystick readings? A: You can increase the precision by using the full range of the analog input and ensuring that the joystick is properly calibrated.
Q: Is it possible to use the joystick without the switch feature?
A: Yes, the switch is optional. If you do not need the switch functionality, you can leave the SW
pin disconnected.