Pulse Width Modulation (PWM) via Software

Words
55
Reading
1 min
Listen
Play
8y

Pulse-width modulation is a technique that allows a microcontroller to control the speed of motors, brightness of LEDs, or average voltage without needing a DAC. If you don't have a microcontroller with on-board PWM hardware, or have run out of PWM channels, how can PWM be simulated using software?

The flow diagram
PWM.png

The C code

F.jpg

Pulse Width Modulation (PWM) via Software | Ecency