I am using servo motor for some positioning. Let's said I want the servo motor rotate to a specific angle like 23 degree, is it possible to achieve using Raspberry PI? Did I need some sort of encoder to do alignment?

  • Nothing to do with the Pi.
    – joan
    Jul 13, 2018 at 19:32
  • @Geddoe, please edit your question to explain how you are using a Raspberry Pi and what solutions you have tried, etc. As worded, this question is not acceptable.
    – OyaMist
    Jul 13, 2018 at 22:41
  • I am using servo motor for some positioning .... you are already using the servo, so why do you not run a test to see if you can position it to a specific angle. ..... your question is like this one I am driving my car. Can someone tell me if I can turn to the right?
    – jsotola
    Jul 14, 2018 at 0:39
  • sorry, I forgot to put Raspberry PI >.< ... Since I haven't start this project and I scare after I bought all the things, all not working...
    – Geddoe
    Jul 14, 2018 at 4:12
  • "is it possible to achieve using Raspberry PI" -> If it's possible then sure, but your question is still about servo motors and the Pi is just irrelevant tangent.
    – goldilocks
    Jul 14, 2018 at 17:55

1 Answer 1


Servo motors are controlled by pulse width modulation (PWM). Specifically, the angular position of the servo is determined by a specific pulse width. The angular position will be approximate and may even differ from servo to servo. The angular position may also be affected by torque.

Given this behavior, feedback is generally required for exact positioning (e.g., 23 degrees) of servo motors. Such feedback is quite often provided by a rotary encoder. You will need software to control the servo and have it go to a specific position as indicated by the rotary encoder. And yes, that is as complicated as it sounds.

An alternate solution is to use a stepper motor. Stepper motors are designed for digital positioning and can be used with or without rotary encoders depending on your precision needs, but you may need a sensor to establish home position. You may want to consider microstepping for highest positional accuracy.

  • Stepper motors cannot move to a specific angle -- their movement is in well defined angle increments. To move to a specific angle you need a sensor of some sort either to measure the current angle or to establish a well known starting point.
    – Craig
    Jul 13, 2018 at 20:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.