Created
October 24, 2020 04:46
-
-
Save sonus/5b639d7ab1bee47fadba424caa7f4add to your computer and use it in GitHub Desktop.
rasp
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 | |
servoPIN = 17 | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(servoPIN, GPIO.OUT) | |
p = GPIO.PWM(servoPIN, 50) # GPIO 17 for PWM with 50Hz | |
p.start(2.5) # Initialization | |
try: | |
while True: | |
p.ChangeDutyCycle(5) | |
time.sleep(0.5) | |
p.ChangeDutyCycle(7.5) | |
time.sleep(0.5) | |
p.ChangeDutyCycle(10) | |
time.sleep(0.5) | |
p.ChangeDutyCycle(12.5) | |
time.sleep(0.5) | |
p.ChangeDutyCycle(10) | |
time.sleep(0.5) | |
p.ChangeDutyCycle(7.5) | |
time.sleep(0.5) | |
p.ChangeDutyCycle(5) | |
time.sleep(0.5) | |
p.ChangeDutyCycle(2.5) | |
time.sleep(0.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