Servo Position Feedback System With Arduino

Introduction: Servo Position Feedback System With Arduino

Hey their, This is my first instructable. MY project allows you to receive your servo's position

on your serial monitor or serial plotter of your Arduino IDE. This makes easy to program arduino robots which use servo motors like humanoid robots bipedal robots spider robots etc; as you can track your servo position and upload motion in form of servo position in degrees into your Arduino.

(please vote me for the Arduino contest)

Step 1: Step 1 : Tools Required

  1. Arduino nano(or any)
  2. Breadboard
  3. Few jumper wires
  4. Servo motor(SG-90)
  5. Trim-pot (Potentiometer)
  6. Screw driver (optional)
  7. Arduino IDE

Step 2: Connections

  • Note:- I have used a variable resistor to control the servo as it makes easy to control the servo shaft
    1. servo shaft can be turned by hand also
    2. Connect mid pin of the trim-pot to Arduino pin A2.
    3. Connect the servo signal pin to Arduino pin D9.
    4. Connect the other Negative and Positive wires as shown in the Schematic image.
    5. Note:- some servo are tight from inside and are hard to rotate with hand so,take care of servo instead of using hand use the trim-pot to rotate the servo.

Step 3: Uploading the Program to Arduino

The main work to make arduino to function as we want so,let us upload the code to the arduino.

Connect your arduino to your PC and upload the code.

Code is given in the video description.

Step 4: Testing Our System

Finally the last thing to do;testing our servo feedback system.

Open your serial monitor of Arduino IDE and test the system.

Note:- the position feedback can be seen on the serial plotter "you will see some kind of big and small fluctuations on the serial plotter the fluctuations are the PWM signals sent by arduino to the servo in intervals of time."

Arduino Contest 2019

Participated in the
Arduino Contest 2019

Be the First to Share


    • Crayons Challenge

      Crayons Challenge
    • Teach With Tinkercad Contest

      Teach With Tinkercad Contest
    • Back to School: Student Design Challenge

      Back to School: Student Design Challenge



    2 years ago

    Hi Dhana, I cannot find the code. You say "Code is given in the video description." But which video do you mean?


    Reply 2 years ago

    I Had some trouble to upload the code. sorry for your inconvenience,
    Here is the code 👇👇👇👇 Enjoy! & if you want the ".ino file " then email me.

    //Created by Dhananjay khengare on 9_may_2019 Email-
    #include <Servo.h>
    Servo myservo; // create servo object to control a servo
    void setup() {
    myservo.attach(5); // attaches the servo on pin 9 to the servo object
    void loop() {
    int potpin = A2;
    int val;
    int potpin2 = A1;
    int val2;
    val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
    val2 = analogRead(potpin2);
    val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
    val2 = map(val2 , 0 ,1023 , 0 , 180 );
    myservo.write(val); // sets the servo position according to the scaled value
    delay(15); // waits for the servo to get there
    float degree = val + (0/108);
    float degree2 = val2 + (0/108);
    Serial.println(degree , degree2);
    Serial.print(" current servo position in degrees = " );


    3 years ago

    Thanks for sharing your servo Instructable!