Skip to content

Instantly share code, notes, and snippets.

@Ardakilic
Created June 6, 2015 14:28
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 Ardakilic/b1cbd8d8d9c4d8752baf to your computer and use it in GitHub Desktop.
Save Ardakilic/b1cbd8d8d9c4d8752baf to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
PINNO = 7
GPIO.setup(PINNO, GPIO.OUT)
p = GPIO.PWM(PINNO, 50)
p.start(0)
try:
while True:
for i in range(100):
p.ChangeDutyCycle(i)
time.sleep(0.02)
for i in range(100):
p.ChangeDutyCycle(100-i)
time.sleep(0.02)
except KeyboardInterrupt:
pass
p.stop()
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment