The Analog Joystick is an input device that provides two-dimensional analog input, typically used for controlling movement in games or for precise control in various applications. It consists of two potentiometers (one for the X-axis and one for the Y-axis) and a push-button switch. The joystick can be used to detect the direction and magnitude of movement, making it ideal for applications such as robotics, remote controls, and interactive projects.
Parameter | Value |
---|---|
Operating Voltage | 5V DC |
X-axis Range | 0V to 5V |
Y-axis Range | 0V to 5V |
Push-button | Active Low (0V when pressed) |
Dimensions | 40mm x 40mm x 32mm |
Pin Number | Pin Name | Description |
---|---|---|
1 | GND | Ground |
2 | +5V | Power Supply (5V) |
3 | VRx | Analog Output for X-axis (0V to 5V) |
4 | VRy | Analog Output for Y-axis (0V to 5V) |
5 | SW | Digital Output for Push-button (Active Low) |
Power Supply:
+5V
pin of the joystick to the 5V
pin on the Arduino UNO.GND
pin of the joystick to the GND
pin on the Arduino UNO.Analog Outputs:
VRx
pin to an analog input pin on the Arduino UNO (e.g., A0
).VRy
pin to another analog input pin on the Arduino UNO (e.g., A1
).Push-button:
SW
pin to a digital input pin on the Arduino UNO (e.g., D2
).// Define the pins for the joystick
const int VRxPin = A0; // X-axis
const int VRyPin = A1; // Y-axis
const int SWPin = 2; // Push-button
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Set the push-button pin as input with internal pull-up resistor
pinMode(SWPin, INPUT_PULLUP);
}
void loop() {
// Read the analog values from the joystick
int xValue = analogRead(VRxPin);
int yValue = analogRead(VRyPin);
// Read the digital value from the push-button
int buttonState = digitalRead(SWPin);
// Print the 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 to avoid flooding the serial monitor
delay(100);
}
Inconsistent Analog Readings:
Push-button Not Responding:
SW
pin is connected to a digital input pin on the Arduino. Use a pull-up resistor if necessary.Joystick Not Centering:
By following this documentation, you should be able to effectively integrate and use the Analog Joystick in your projects. Whether you are a beginner or an experienced user, this guide provides the necessary information to get started and troubleshoot common issues.