Created
November 10, 2018 21:21
-
-
Save ducky-hong/c67a86fc5b83962d62d89dc4aebffcd7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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, 50) | |
p.start(7.5) | |
try: | |
while True: | |
p.ChangeDutyCycle(7.5) # turn towards 90 degree | |
time.sleep(1) # sleep 1 second | |
p.ChangeDutyCycle(2.5) # turn towards 0 degree | |
time.sleep(1) # sleep 1 second | |
p.ChangeDutyCycle(12.5) # turn towards 180 degree | |
time.sleep(1) # sleep 1 second | |
except KeyboardInterrupt: | |
p.stop() | |
GPIO.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment