Skip to content

Instantly share code, notes, and snippets.

@tpyykola
Created May 2, 2018 14:16
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 tpyykola/3eae29860614cc33f05da25afe3bc67f to your computer and use it in GitHub Desktop.
Save tpyykola/3eae29860614cc33f05da25afe3bc67f to your computer and use it in GitHub Desktop.
import RPi.GPIO as GPIO
from time import sleep
port = 05
def setAngle(angle):
duty = angle / 18 + 2
GPIO.output(port, True)
pwm.ChangeDutyCycle(duty)
sleep(1)
GPIO.output(port, False)
pwm.ChangeDutyCycle(0)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(port, GPIO.OUT)
pwm=GPIO.PWM(port, 50)
pwm.start(0)
setAngle(10)
pwm.stop()
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment