Import RP1.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings (False)
GPIO.setup(20, GPIO.OUT)
GPIO.setup(21, GPIO.OUT)
p1-GPIO.PWM(20,100)
p2-GPIO.PWM(21,100)
p1.start(0)
p2.start(0)
try:
while True:
for dc in range(0,101,5):
p1.ChangeDutyCycle(dc)
p2.ChangeDutycle(dc)
time.sleep(0.025)
for dc in range(100,-1,-5):
p1.ChangeDutyCycle(dc)
p2.ChangeDutyCycle(dc)
time.sleep(0.025)
except KeyboardInterrupt:
pass
p1.stop()
p2.stop()
GPIO.output(20,GPIO.LOW)
GPIO.output(21,GPIO.LOW)
GPIO.Cleanup ()