Issue with modulating PWM
A Python module to control the GPIO on a Raspberry Pi
Brought to you by:
croston
Model Raspberry Pi 2 Model B V1.1
Raspbian GNU/Linux 7 / Linux raspberrypi 4.1.7-v7+
RPi.GPIO 0.5.11
Expected: LED should flash for 3 seconds, switch off for three seconds, then flash for three seconds.
Actual: The second time the LED comes on, it does not flash. It is continuous.
import RPi.GPIO as GPIO from time import sleep pin = 12 frequency = 5 dutycycle = 50 GPIO.setmode(GPIO.BCM) GPIO.setup(pin, GPIO.OUT, initial=GPIO.LOW) led = GPIO.PWM(pin, frequency) led.start(dutycycle) sleep(3) led.stop() sleep(3) led.start(dutycycle) sleep(3) led.stop() GPIO.cleanup()