PyRaspBeta

← All practice problems

Raspberry Pi practice problem · LEDs & PWM

Two hundred hertz

EasyBudget $2Python · gpiozero

PWM has two knobs: how often the pin switches (frequency) and how long it stays on each time (duty cycle).

Using RPi.GPIO, run PWM on GPIO12 at 200 Hz with a 60 % duty cycle, with an LED on that pin, and keep it running.

Tip: GPIO.PWM(pin, frequency) then .start(duty_percent). Keep the program alive afterwards (while True: sleep(1)).

More in LEDs & PWM