Skip to content

Instantly share code, notes, and snippets.

@simform-solutions
Created September 21, 2017 09:58
Show Gist options
  • Save simform-solutions/dc1e6beec02303d8f36541a340485f57 to your computer and use it in GitHub Desktop.
Save simform-solutions/dc1e6beec02303d8f36541a340485f57 to your computer and use it in GitHub Desktop.
#rotate servo motor according to transaction
def rotate_motor():
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(25, GPIO.OUT)
pwm=GPIO.PWM(25,50)
pwm.start(7.5)
try:
pwm.ChangeDutyCycle(7.5)
time.sleep(1)
pwm.ChangeDutyCycle(2.5)
time.sleep(1)
pwm.ChangeDutyCycle(12.5)
time.sleep(1)
pwm.ChangeDutyCycle(0)
time.sleep(1)
pwm.stop()
except KeyboardInterrupt:
pwm.stop()
finally:
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment