Servo motor control with Joystick and Arduino
In this tutorial, we are going to learn how to make a Servo motor control with joystick and Arduino. In this project, we are going to control the angular position of the servo motor depending on the input given to the Joystick. For this project, the required components are:-
->Servo Motor
->Joystick Module
->Arduino Uno R3
->Bread Board
->Male-Male, Male-Female connecting wires
Servo motor
A Servo motor is a type of motor that is used for precise angular and linear positions. It can rotate up to 180 degrees. The Servo motor is a closed-loop system where it uses feedback to control the motion of the motor. It is used in various electronic devices like DVDs, toy cars, robotics, etc, and many more. There is a total of 3 wires on the servo motor namely Vcc, GND, and Control pin.
Pin configuration of Servo motor
WIRE OF MOTOR | COLOR OF EACH WIRE |
Vcc pin(5V) | Red |
GND pin | Brown |
Control or PWM pin | Yellow or Orange |
Joystick module
Joystick Module is a very simple module that consists of two variable resistors (or potentiometers) and a push button. Variable resistors provide analog outputs whereas push button generates output in digital form either high state or low state. One potentiometer is for X-axis and the other potentiometer is for Y-axis. THE JOYSTICK module consists of 5 pins. The description of each pin is given below.
Pin description of Joystick module
Pin no. | Pin | Description |
1 | GND | Connect to the ground terminal of the Arduino. |
2 | +5V | Connect to the 5v pin of the Arduino |
3 |
VRx | It gives output with respect to the joystick’s X-axis (left/right) position. |
4 |
VRy | It gives output with respect to the joystick’s Y-axis (up/down) position. |
5 |
SW | It gives the output obtained from the push button. If the button is pressed the output will be low (0) and when it is released the output will be high(1). |
Circuit diagram for Servo motor control with Joystick and Arduino

Follow the connection as explained below:-
Connection of Servo with Arduino
Step 1:- Connect the Red wire(Vcc) of the servo to the 5v pin of the Arduino.
Step 2:- Connect the Brown wire(GND) of the servo to the GND pin of the Arduino.
Step 3:- Connect the Yellow/Orange wire(control signal) of the servo to the digital pin 9 of the Arduino. //This pin no 9 is for the X-axis position of the joystick
Step 4:- Connect the Yellow/Orange wire(control signal) of the servo to the digital pin 10 of the Arduino. //This pin no 10 is for the Y-axis position of the joystick
Connection of Joystick module with Arduino
Step 1:- Connect the joystick’s GND pin to Arduino’s GND pin.
Step 2:- Connect the +5v pin of the joystick to the 5v pin of Arduino.
Step 3:- Connect the VRX pin of the joystick to the analog pin A0 of the Arduino.
Step 4:- Connect the VRY pin of the joystick to the analog pin A1 of the Arduino.
Step 5:- Connect the SW pin of the joystick to the digital pin 2 of the Arduino.
***IMPORTANT NOTE:- In the above tutorial on Servo motor control with joystick and Arduino, we are using only 1servo for demonstration. The joystick has 2 position axis x & Y. In the given code below we have considered both the axis for the servo control. You can control the servo from either of the axis for a better understanding of the working principle of the joystick.
Code for the Project
Author
K Sai Kamal Kumar