Main Content

Raspberry Pi PWM

The Raspberry Pi™ hardware board supports software pulse-width modulation (PWM) on all GPIO pins. When configured for PWM, each pin outputs a square waveform with variable frequency and duty cycle.

The minimum PWM output frequency is 10 Hz. The maximum PWM output frequency is 8 KHz using writePWMFrequency(mypi, 12, 8000).

A duty cycle of0means that the waveform is always low. A duty cycle of1means the waveform is always high.

To use a PWM pin, configure the GPIO pin as a PWM pin using theconfigurePinfunction.

To see the available GPIO pins onraspberrpiobject, use theshowPinsfunction.

showPins(mypi)

See Also

||