I have a Raspberry Pi 3 (Model B). I'm trying to drive a servo motor (Tower Pro MG 995). I am using a 6V power supply (4 AA batteries) connected to power and ground of the servo motor. I attach the battery ground to the GND of the pi and the signal wire to GPIO pin 18 on the Raspberry Pi. I'm running the following code:

# Import GPIO Libraries
import RPi.GPIO as GPIO
import time

GPIO.setup(18, GPIO.OUT)
p = GPIO.PWM(18, 50)

I'm running this from a Jupyter notebook, and when I measure the signal going into the motor signal wire at this point I get this:

enter image description here

The motor does not move at all.

I can then call:


Which changes the pulse width just as one would expect, and the motor does not turn at all.

When I initially plug in the motor to power, it jumps "forward" a certain angle. When I remove and reapply power to the motor it jumps "forward" again the same amount. I can repeatedly do this until it reaches the end of its range.

I've tried three different motors and get no movement at all when setting or changing the input signal.

Any ideas about what I'm missing, or what else I can try?



  • 1
    That seems correct as far as it goes. A photo of your wiring is needed. – joan Jun 25 '17 at 7:03
  • OK, thanks for the validation and the call to photo the wiring. It gave me the idea to recheck all the connections. It turns out the ground wire from the motor ground to the pi was not making connection (protoboard issue). So, I can vouch for the approach above -- it's working now! Thanks again for the "correct as far as it goes" comment -- actually more helpful than you know. – Travis Vaught Jun 25 '17 at 21:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.