Skip to content

Instantly share code, notes, and snippets.

@duffyd
Created December 22, 2021 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duffyd/7058340241c425050aaab6cd4f7e7b67 to your computer and use it in GitHub Desktop.
Save duffyd/7058340241c425050aaab6cd4f7e7b67 to your computer and use it in GitHub Desktop.
import RPi.GPIO as GPIO
import time
servoPIN = 12
GPIO.setmode(GPIO.BCM)
GPIO.setup(servoPIN, GPIO.OUT)
p = GPIO.PWM(servoPIN, 50)
p.start(5) # Initialization
try:
while True:
p.ChangeDutyCycle(2.5)
time.sleep(5)
p.ChangeDutyCycle(11.5)
time.sleep(5)
p.ChangeDutyCycle(20.5)
time.sleep(5)
p.ChangeDutyCycle(11.5)
except KeyboardInterrupt:
p.stop()
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment