

The JOYSTICK_MINI is a compact input device designed for directional control and movement detection. It features a pivoting stick that allows users to interact with systems by detecting movement in multiple directions. This component is widely used in applications such as gaming controllers, robotics, remote-controlled devices, and other interactive systems requiring precise directional input.








The JOYSTICK_MINI typically has 5 pins. The table below describes each pin:
| Pin | Name | Description |
|---|---|---|
| 1 | GND | Ground connection for the joystick. |
| 2 | VCC | Power supply input (3.3V to 5V). |
| 3 | VRx | Analog output for the X-axis movement. Voltage varies based on joystick position. |
| 4 | VRy | Analog output for the Y-axis movement. Voltage varies based on joystick position. |
| 5 | SW | Digital output for the push-button. Active LOW when pressed. |
Powering the Joystick:
Reading X and Y Axis Values:
Using the Push-Button:
The following code demonstrates how to read the X and Y axis values and detect button presses using an Arduino UNO.
// Define pin connections for the joystick
const int VRxPin = A0; // X-axis connected to analog pin A0
const int VRyPin = A1; // Y-axis connected to analog pin A1
const int SWPin = 2; // Push-button connected to digital pin 2
void setup() {
// Initialize serial communication for debugging
Serial.begin(9600);
// Configure the push-button pin as input with internal pull-up resistor
pinMode(SWPin, INPUT_PULLUP);
}
void loop() {
// Read the X and Y axis values (0 to 1023 for 10-bit ADC)
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 X or Y Axis:
Button Not Responding:
INPUT_PULLUP in your code.Inconsistent or Noisy Readings:
Joystick Not Centered:
Q: Can the JOYSTICK_MINI be used with a Raspberry Pi?
A: Yes, the joystick can be used with a Raspberry Pi. However, since the Raspberry Pi lacks analog input pins, you will need an external ADC (Analog-to-Digital Converter) module to read the X and Y axis values.
Q: What is the lifespan of the joystick?
A: The lifespan depends on usage and environmental conditions. Under normal use, the joystick can last for thousands of cycles.
Q: Can I use the joystick for 360-degree control?
A: Yes, the joystick provides analog outputs for both X and Y axes, allowing for smooth 360-degree directional control.
Q: Is the push-button necessary for operation?
A: No, the push-button is optional and can be left unconnected if not required for your application.