Controlling Servo Angle using Joystick in Arduino IDE

Controlling Servo Motor
About This Tutorial
In this tutorial we will control the position of a RC (hobby) servo motor with a Joystick.
Tutorial Info


In this tutorial we will control the position of a RC (hobby) servo motor with a Joystick.

A servo motor is a rotary actuator that allows for precise control of angular position.  It consists of a suitable motor coupled to a sensor for position feedback.

Metal Servo motor

Control using evive and Arduino IDE

evive has two dedicated servo motor outputs pins.

Signal pin of servo 1 is connected to digital pin 44 and servo 2 is connected to digital pin 45.

evive servo output channel

Circuit Diagram

In the following example, I will be showing you how to control servo through channel 1. Given below is the circuit diagram:

evive Servo Joystick

A Servo pin has three wires (Order to be connected in evive, left to right)

  • Brown wire: GND
  • Red wire: VCC
  • Orange wire: Signal
Caution: Power evive using a 12V 2A power adapter for smooth functioning of servo motor. The VVR (Variable voltage) should be close to 6V.

A Joystick have 5 pins:

  • Ground
  • 5V
  • VRx: X position connects to Analog pin 0
  • VRy: Y position
  • SW: Z press

How Joystick works?

Joystick has 2 potentiometers and a switch.
A potentiometer has a wiper sliding on a resistive strip. If the wiper is close to GND, it outputs 0V, and if it is close to VCC or 5V, it outputs 5V.
In Arduino IDE,  if the wiper is close to GND you get 0 value and if it close to VCC, you get 1023. Hence you get approx. 512 when joystick is at default position.


[pastacode lang=”c” manual=”%23include%20%3Cservo.h%3E%0A%0Adouble%20Angle%3B%0Adouble%20Potentiometer%3B%0AServo%20servo_3%3B%0A%0Avoid%20setup()%7B%0A%20Angle%20%3D%200%3B%0A%20pinMode(A0%2CINPUT)%3B%0A%20servo_44.attach%7B44)%3B%20%2F%2F%20init%20pin%0A%7D%0A%0Avoid%20loop()%7B%0A%20Potentiometer%20%3D%20analogRead(A0)%3B%0A%20Angle%20%3D%20((Potentiometer)%20*%20(180))%20%2F%20(1023)%3B%0A%20servo_44.write(Angle)%3B%20%2F%2F%20write%20to%20servo%0A%20delay(50)%3B%0A%7D” message=”” highlight=”” provider=”manual”/]

Control using Arduino Uno

Arduino uno has 6 PWM pins: 3, 5, 6, 9, 10, and 11 which provide 8-bit PWM output with the analogWrite() function.

We will controlling servo using Pin 3.

Circuit Diagram

Caution: Power servos using a 6V 2A power adapter for smooth functioning of servo motor.


[pastacode lang=”c” manual=”%23include%20%3Cservo.h%3E%0A%0Adouble%20Angle%3B%0Adouble%20Potentiometer%3B%0AServo%20servo_3%3B%0A%0Avoid%20setup()%7B%0A%20Angle%20%3D%200%3B%0A%20pinMode(A0%2CINPUT)%3B%0A%20servo_3.attach(3)%3B%20%2F%2F%20init%20pin%0A%7D%0A%0Avoid%20loop()%7B%0A%20Potentiometer%20%3D%20analogRead(A0)%3B%0A%20Angle%20%3D%20((Potentiometer)%20*%20(180))%20%2F%20(1023)%3B%0A%20servo_3.write(Angle)%3B%20%2F%2F%20write%20to%20servo%0A%20delay(50)%3B%0A%7D” message=”” highlight=”” provider=”manual”/]

Share this Tutorial
Share on facebook
Share on twitter
Share on google
Share on pinterest
Share on reddit
Share on print
Related Projects & Tutorials
How to interface Water Flow sensor with evive
In this tutorial, we will discuss how to interface water flow sensor with evive. How water flow rate, current water flowing and output water changes? The water flow rate in liters per hour, current water flowing and output water flowing data flowed since starting is displayed on the screen. All the answers are given in this tutorial.LET'S BEGIN...
ldr circuit
How to interface LDR sensor with evive ?
The tutorial will shows how to interface ldr sensor with evive and controlling the led state using the sensor.How does ldr sensor works? How to control lights using ldr sensor? All the answers are given in this tutorial.Let's begin...
All articles loaded
No more articles to load
Featured Projects
All articles loaded
No more articles to load

Leave a Reply

Close Menu


Registrations for Codeavour 2019 are OPEN!
Participate in this unique coding contest and stand a chance to win exciting prizes!