2

Helpful link: https://github.com/naoto64/piServoCtl

The code is copied below:

from piservo import Servo
import time

myservo = Servo(12)

def rotate():
    myservo.write(180)
    time.sleep(1)
    myservo.stop()

rotate() # running the function once works fine
rotate() # trying to run it a second time throws the error: "The function start is not 
being executed"

I'm at a loss as to what to do at this point. I'm using a continuous rotation servo and the above code is the only script I can get to work at this point. The code is somewhat misleading. myservo.write(180) determines the speed of rotation. time.sleep(1) determines the amount of time the servo rotates. The manual for the piServoCtl doesn't define the above functions as doing what is written above, I've just found this through experimentation. Admittedly that doesn't matter, I would just like to be able to call function multiple times. Any help would be greatly appreciated.

SamsUncle
  • 21
  • 1
  • 1
    `.stop()` is completely shutting down the `Servo` object, you'd have to recreate it to use it again. Just call `.write()` with a mid-range value to make the servo idle but still be usable later. – jasonharper Apr 24 '21 at 03:02
  • Thanks for the reply. Starting the function with myservo.start() works. – SamsUncle Apr 26 '21 at 00:14

0 Answers0