

The Analog Joystick is an input device that allows for two-dimensional control by detecting the position of a stick that pivots on a base. It is commonly used in gaming controllers, robotics, and other applications requiring precise navigation or control. The joystick typically provides two analog outputs corresponding to the X and Y axes, and often includes a push-button feature for additional functionality.








The Analog Joystick is a simple yet versatile component. Below are its key technical details:
The Analog Joystick 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 position (0V to Vcc). |
| 4 | VRy | Analog output for the Y-axis position (0V to Vcc). |
| 5 | SW | Digital output for the push-button (LOW when pressed, HIGH when released). |
VCC pin to a 3.3V or 5V power source and the GND pin to ground.VRx and VRy pins to the analog input pins of your microcontroller (e.g., Arduino).SW pin to a digital input pin of your microcontroller. Use a pull-up resistor if necessary.Below is an example of how to use the Analog Joystick with an Arduino UNO:
// Define pin connections
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)
int xValue = analogRead(VRxPin);
int yValue = analogRead(VRyPin);
// Read the push-button state (LOW when pressed)
int buttonState = 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(buttonState == LOW ? "Pressed" : "Released");
// Add a small delay for stability
delay(100);
}
Joystick Outputs Incorrect Values
Push-Button Not Responding
INPUT_PULLUP mode in your microcontroller or add an external pull-up resistor.Joystick Does Not Return to Center
No Output from X or Y Axis
VRx and VRy pins are connected to analog inputs.Q: Can I use the joystick with a Raspberry Pi?
A: Yes, the joystick can be used with a Raspberry Pi. Connect the VRx and VRy pins to the Pi's ADC (via an external ADC module, as the Pi lacks built-in analog inputs).
Q: How do I calibrate the joystick?
A: Read the X and Y axis values when the joystick is centered. Use these values as the midpoint in your code and map the range accordingly.
Q: Is the joystick waterproof?
A: No, most analog joysticks are not waterproof. Use protective enclosures for outdoor applications.