Menu

#116 Issue with modulating PWM

New
nobody
pwm (4)
Medium
Defect
2015-10-03
2015-10-03
aidan
No

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()

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.