Joystick Control Using Arduino Uno
Learn how to interface a joystick module with Arduino Uno and read its X-axis, Y-axis, and push-button values. This simple 5-wire connection project is perfect for beginners in robotics, game controls, and remote control systems.
Joystick to Arduino Connection (5 Wires Only)
The joystick module has 5 pins:
| Joystick Pin | Arduino Connection | Function |
|---|---|---|
| VRX | A0 | X-axis analog input (0–1023) |
| VRY | A1 | Y-axis analog input (0–1023) |
| SW | Pin 2 | Push button (LOW when pressed) |
| +5V | 5V | Power supply |
| GND | GND | Ground |
That’s it — just five wires!
How the Joystick Works
Inside the joystick module:
-
It contains two potentiometers
-
Each potentiometer outputs a voltage between 0V to 5V
-
Arduino converts this voltage into digital values from 0 to 1023
Axis Behavior
-
Center Position: Around 512
-
Move Left: X value decreases (toward 0)
-
Move Right: X value increases (toward 1023)
-
Move Up: Y value increases
-
Move Down: Y value decreases
Button (SW Pin)
-
When pressed → LOW
-
When released → HIGH
-
Works like a normal push button (internally connected to ground when pressed)
Arduino Code Example
const int xPin = A0;const int yPin = A1;const int swPin = 2;void setup() {Serial.begin(9600);pinMode(swPin, INPUT_PULLUP);}void loop() {int xValue = analogRead(xPin);int yValue = analogRead(yPin);int buttonState = digitalRead(swPin);Serial.print("X: ");Serial.print(xValue);Serial.print(" | Y: ");Serial.print(yValue);Serial.print(" | Button: ");Serial.println(buttonState == LOW ? "Pressed" : "Released");delay(200);}
What This Code Does
-
analogRead(A0)→ Reads horizontal movement -
analogRead(A1)→ Reads vertical movement -
digitalRead(2)→ Detects button press -
Serial Monitor displays live joystick data
Applications of Joystick with Arduino
Educational Benefits
Students learn:
-
Analog input reading
-
Digital input detection
-
Understanding potentiometers
-
Serial communication
-
Basic interactive control systems
This is one of the most important beginner projects in robotics and embedded systems.
CLICK BELOW LINK TO DOWNLOAD THE CODE
BEGINNER PROJECTS (Foundation Skills)
- Ultrasonic Distance Measurement
- Traffic Light Simulation with 7-Segment Display
- 7-Segment Display Counter
- Kids Piano Circuit (8-Key Version)
- 16×2 LCD Display with Text Output
- LCD I2C to Arduino UNO
- Temperature Measurement using Arduino UNO
- LDR Controlled Street Light
INTERMEDIATE PROJECTS (Build Your Skills)
- Servo Motor Control Using Potentiometer
- DC Motor Speed Control
- Temperature Controlled Fan
- PIR Based Theft Alert System
- LPG Gas Leakage Detection System
- Automatic Door Locking System
- Soil Moisture Based Automatic Watering System
- Simple Digital Clock using Arduino UNO
- Automatic Voting Machine (EVM)
- Joystick Control using Arduino Uno
- RGB Lamp Control using Arduino Uno
ADVANCED PROJECTS (Master Level)
- Home Automation Using Arduino UNO
- Bluetooth RC Car using Arduino Uno
- Obstacle Avoiding Robot
- Line Follower Robot
- Radar System Using Arduino UNO
- Automatic Parking System
- Bi-Directional People Counter using Arduino Uno
- Automatic Plant Watering System
- NeoPixel LED Ring Control using Arduino Uno
- Smart Gloves for Bedridden People
Comments
Post a Comment