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.
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.
In the following example, I will be showing you how to control servo through channel 1. Given below is the circuit diagram:
A Servo pin has three wires (Order to be connected in evive, left to right)
A Joystick have 5 pins:
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.
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.