import RPi.GPIO as GPIO import time mota = 22 motb = 23 GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(mota,GPIO.OUT) GPIO.setup(motb,GPIO.OUT) p1 = GPIO.PWM(mota, 100) # GPIO PWM with 50Hz p2 = GPIO.PWM(motb, 50) # GPIO PWM with 50Hz print "CTRL+C = STOP program" try: while True: n = 100 p1.start(0) p1.ChangeDutyCycle(n) time.sleep(1) p1.stop() GPIO.output(mota,GPIO.LOW) time.sleep(2) n = 30 p2.start(0) p2.ChangeDutyCycle(n) time.sleep(1) p2.stop() GPIO.output(motb,GPIO.LOW) time.sleep(2) except KeyboardInterrupt: GPIO.cleanup() # must be executed before program stop