I'm trying to get some Servos to work with Python on my Raspberry Pi:
And for some reason I can't get them to reverse with this script:
#Okay, so a duty cycle of 2 is full charge clockwise, while 12 is full charge counter clockwise. #As they get closer to each other they slow down. With the servo I'm currently testing 7 seems to be the part where clock wise hits close to stopping. #Only 0 seems to get you to absolute stillness. #When messing with the arm servos, it will only go one way, but functions like a clock and only goes 120 deg. import RPi.GPIO as GPIO import time servoPin = 17 GPIO.setmode(GPIO.BCM) GPIO.setup(servoPin, GPIO.OUT) p = GPIO.PWM(servoPin, 50) # GPIO 17 for PWM with 50Hz p.start(0) # Initialization #0 seems to stop and hold it try: while True: dutyCycle = input("Type new duty cycle as decimal number...\n") #Min Duty cycle seems to be 1.65 but is virtually identical to 2. Min is fastest with 6 being a relative slowest while not just grinding. p.ChangeDutyCycle(float(dutyCycle)) input("Press enter to stop...\n") p.ChangeDutyCycle(0) except KeyboardInterrupt: print("\nStopping and Cleaning...\n") p.stop() GPIO.cleanup()
1 through 15 seem to be all the different positions, but it only will only let me go down.
I can tell it to go to 5 then 4 then 3 etc.
but I can't tell it to go back up to 5 or 15.
Going past the scale doesn't help either as I tried a little incremental script to see where it actually moves (to see if it at least jiggled anywhere else from 1 to 100) and nothing got it to move.
I've tested with different servos and it seems to work with them, in fact the notes in the code I've included mention these and what works for them.
What am I doing wrong?