Create a gist now

Instantly share code, notes, and snippets.

@tpyykola /servo.py Secret
Created May 2, 2018

What would you like to do?
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