top of page

SERVO MOTOR CONTROLLED BY JOYSTICK

Updated: Mar 25


Ever heard of a joystick? The answer would be obviously yes for people who like playing video games and also who are tech-savvy. What if I mention a thumb joystick, the first thing that comes to your mind eventually is game controllers. Definitely, it is used for playing games but it also acts as a great addition in DIY Electronics, and there are a lot of fun things that one can do with it.


This article covers the working and configuration of servo motor controlled by thumb joystick using Arduino in detail.


List Of Components Used


1. Servo motor

A servo motor is actually a rotary actuator that gives precise control in terms of its angular position, acceleration, and velocity. A servo motor works on the principle of PWM (Pulse width modulation). This implies that depending on the width of the pulse that is applied the rotor will turn in the desire position. For this interfacing, an SG90 servo motor is used. The white piece in the picture is a rotor and is controlled by a bunch of gears inside. If a DC source powers the motor then it is called a DC servo motor and if powered by an AC source then it is called an AC servo motor.

Image showing a SG90-Servo motor
SG90 Micro-Servo Motor Image

Buy SG90- Servo Motor from here.


2. Arduino Board

Arduino Board can read inputs such as light on a sensor, a finger on a button, or a Twitter message and convert it to an output such as activating a motor, turning on an LED, publishing something online. All of this can be done by sending a set of instructions to the microcontroller on the board by the use of the Arduino programming language.

Image of an ARDUINO UNO Board
ARDUINO Board

Buy Arduino UNO from here.


3. Thumb Joystick

A #thumb joystick also called an analog joystick that has two potentiometers in it, one on the x-axis and the other on the y-axis, which separates the horizontal and the vertical movements respectively. So when we move this #joystick in the x-y plane the variable resistances of the potentiometer will vary and the Arduino will read this as an analog input. The rotatory head of the servo motor is controlled by the joystick.

Image of a "thumb joystick" to control the servo motor
Thumb Joystick

Buy Thumb Joystick from here.


Circuit Diagram

The circuit below shows the connection of an #SG90 servo motor with the Arduino board and thumb joystick. There are three wires of the servo motor. The brown wire is the ground wire, the red one goes to the 5 volts, and the orange one is called the #PWM wire which is connected to the digital line of the servo motor and the yellow one of the joystick is connected to the analog pin of the Arduino board.

Note: We are using only 3 pins out of the 5 of the thumb joystick in this project.



The hardware arrangement of this project is very simple to make. First and foremost, connect the thumb joystick with the Arduino board. The connections for the thumb joystick and the Arduino board are given as:


Joystick Connection:

  1. Joystick VCC (red wire) --> Arduino 5Volts

  2. Joystick GND (brown wire) --> Arduino GND (grounded)

  3. Joystick x_axis pin (yellow wire) --> #Arduino analog input pin A0

Subsequently, connect the servo motor with the Arduino board. The connections for servo motors with Arduino board are given as:


Servo Connection:

  1. Servo VCC (red wire) --> Arduino 5Volts

  2. Servo GND (brown wire) --> Arduino GND (grounded)

  3. Servo signal pin (orange wire) --> Arduino pin 3



Code :



Note: Please change the file extension to .ino(Arduino IDE) file format before you upload the code to Arduino Board.



Working

Circuit image of whole setup when the switch is in OFF state
Circuit image at switch off state

When the thumb joystick moves along the axis, it gives us values from 0 to 1023, but as servo motor can take only values from 0 to 180 and it is the maximum angle that it can rotate to.


So we are simply converting the x_axis value which is in between 0 and 1023 to 0 and 180. Then by moving the joystick we see the servo motor moves accordingly. When the joystick is moved along the axis, the servo will move towards the right or left.


By changing the mapping value which is now from 0 to 180 to 0 to 90, we check out the results. Then we observe that the servo motor sets itself to a mean position of 45 degrees and moves accordingly from there as we move the joystick around.

Circuit image of whole setup when the switch is in ON state
Circuit image at switch on state

Video By - Aishwarya Balajee

Video explanation of the whole working process for a better understanding.

The article depicts how the Arduino Joystick Interface can be implemented and one can understand the use of the Arduino Joystick in an application where we will control a Servo Motor. The joystick can be used in various applications like controlling DC Motors and Servo Motors, controlling LEDs, Remote-controlled Cars, Robotic Control, etc.

 

See also:




Related Posts

See All
bottom of page