I'm using an rPi to send a GPIO signal to a servo motor. When I run the program, the motor starts turning, and then continues without stopping, even if the program has terminated through the use of a loop or through Ctrl+C. I am not sure why the motor would still be getting signaled to rotate. If anyone has any ideas I would appreciate it! Code here:

import RPi.GPIO as GPIO
import time


GPIO.setup(11, GPIO.OUT)

p.GPIO.PWM(11, 50)

    while True:

        print "running"

except KeyboardInterrupt:

  • Hi @Ryan Mar, Welcome. Ah, let me see. Your program looks OK. What might be wrong is that your servo might not be the standard "180 degrees" servo which turns clockwise and counter clockwise within a range of 180 degrees. You might like to google Adafruit or Rpi for "Non Stop" servos.
    – tlfong01
    Nov 15 '19 at 3:08
  • Or you might like to read my answer to the question of "360 degrees non stop servo": (1) raspberrypi.stackexchange.com/questions/97999/…, (2) raspberrypi.stackexchange.com/questions/98467/….
    – tlfong01
    Nov 15 '19 at 3:15
  • 1
    @tlfong01 I don't quite see how that helps; my problem is that my motor can't stop rotating, not that it won't rotate at all
    – Ryan Mar
    Nov 15 '19 at 5:05
  • 1
    We need a link to the servo you bought and a true listing of the software you are running.
    – joan
    Nov 15 '19 at 9:08
  • 3
    The variable p never seems to be set. Is this all of your code, or did you edit something out?
    – Bex
    Nov 15 '19 at 13:54

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.