When i stop the servo after an action and want to start it again the servo is moving strange. The servo seems to move out of range.
import RPi.GPIO as GPIO
import time
GPIO.setup(17, GPIO.OUT)
p = GPIO.PWM(17, 50)
p.start(2.5)
time.sleep(3)
p.ChangDutyCycle(12.5)
time.sleep(3)
p.ChangDutyCycle(2.5)
time.sleep(3)
p.stop()
p.start(2.5)
# this is not working
p.ChangDutyCycle(12.5)
p.stop()
The servo should normally start again and make the movement. It think it maybe sets the start position wrong and wants to move in the other direction.
I solved the problem not very elegant, but I didn't found any better solution. I made an extra file with all the servo moves and executed it with os.system("path to file")
in the main program. In the separate file I initialized the servo pins and started the servo. At the end I stopped the servo and cleaned only the servo pins to not break the main program with other pins involved. The problem is that you have to set the servos back to the start position at the end of the separate file.