servo motor odd behaviour

Active today
Viewed 23 times

hello I Connected a servo motor to my Raspberry pi Zero W

and used the example from raspberrypi.org: granpa scarer:

Grandpa Scarer

and the servo worked however after changing the value for: p.ChangeDutyCycle(3) to an other value the servo stopped working it makes a sound like it trying to move but can’t.

I changed it back to it’s original value but the problem remains I switched to an other servo that I had and that one worked, so I switched back to the first one (a smaller one) and now it worked.

But after playing around with it for a couple of times, the issue came back

Has anybody else experience this?

  • Hi @Kungbjucha, You remind me the first time I played with the servo motor. I followed the tutorial, ran the program, and the servo moved to different positions as I changed the duty cycle, ie, the width of the pulses input to the signal pin of the servo. So I was happy to have learned what is the meaning of PWM (Pulse Width Modulation) control of a motor. – tlfong01 1 hour ago    
  • Then I tried different duty cycle values, and was happy to see the servo moved further as I increased the pulse width, and moved backward when I decreased the pulse width. So I thought that I learned all the tricks, and tried one more width, but this last time the servo did not move, and started trembling, and drifting away, and as it was going to fall off the desktop, I used a finger to hold it. Then I found one thing weird – the servo was very hot! I immediately pulled the plug, but it was too late. I found the servo seemed dead, never moved again even when I tried the old widths. 😦 – tlfong01 1 hour ago   
  • Thank you for reading my boring, long, and sad story of how I fired the motor, the first one I played. These are the opening paragraphs of my answer to your question. You need to read more of my boring paragraphs to understand my answer: “How can Rpi move a servo motor using a GPIO pin in PWM mode?” raspberrypi.stackexchange.com/questions/98467/…. – tlfong01 57 mins ago   
  • A servo under load will do this if there is not enough current. If you are powering them via a 5V pin, use an external source instead (but make sure to add a common ground). – goldilocks 51 mins ago
  • In case you have already bored to death, and just want a quick reply, here is a hint to the root cause of the odd behaviour of your servo motor: “Servo Position vs Pulse Width (duty Cycle)”: imgur.com/gallery/Q7ruJkJ – tlfong01 46 mins ago   
  • Thank you for that answer, I will look into it – Kungbjucha 44 mins ago

2 Answers


This is an old resource, and due for an update. Can I recommend that you have a look at using the gpiozero module to interface with a servo.

from gpiozero import Servo
from time import sleep

servo = Servo(17)

while True:

 New contributor


That is a dreadful tutorial. It really should be deleted or updated.

You need to understand how servos are controlled to use them properly – that tutorial confuses the issue.

A hobby servo is commanded by a series of pulses expected about 50 times per second (50 Hz). The length of the pulse determines the angle of the attached horn. The pulse length is generally given in microseconds.

The centre angle is specified by a pulse length of 1500 µs. Shorter pulses move the horn counterclockwise. Longer pulses move the horn clockwise. Values between 1000 and 2000 µs are safe for most servos. The small 9g servos often respond to pulses in the range 500 to 2500 µs. However every servo is different. If you command it to a position outside its range you can strip the gears and destroy the servo. So be careful and check the safe pulse lengths by experiment.

At 50 Hz PWM each pulse is a maximum of 20000 µs. A 50% dutycycle means the pulse is high for 10000 µs and low for 10000 µs. A 3% dutycycle means the pulse is high for 600 µs and low for 19400 µs. The pulse length is the high part so 3% equates to 600 µs. This may or may not work for your servo.

You need to convert between dutycycles at 50 Hz and the resulting pulse length. You need to establish safe limits for your servos.

  • ah ok, when you first read about them, they seems simple to use. I will investigate what are the limits for my servo. – Kungbjucha 42 mins ago

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: