Created
August 31, 2019 19:33
-
-
Save natcl/38e3cfc2d523afa7510ec97a3af9e667 to your computer and use it in GitHub Desktop.
PWM Servo on Pi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as GPIO | |
import time | |
GPIO.setmode(GPIO.BOARD) | |
GPIO.setup(12, GPIO.OUT) | |
p = GPIO.PWM(12, 100) | |
p.start(5) | |
time.sleep(2) | |
for angle in range (25, 180): | |
duty = float(angle) / 10 + 2.5 | |
print duty | |
p.ChangeDutyCycle(duty) | |
time.sleep(0.15) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment