PWM
Find a light switch in your house with reasonably responsive bulbs (LED bulbs work best). Then, try turning them on and off once per second. Now flick the switch faster and faster until the light in the room appears almost constant. You should notice that it seems dimmer in the room than when you had the light on all of the time, even though the bulb is only ever completely on or completely off.
PWM works in the same way, except that, with the Pi, we can turn the voltage on and off so quickly (and quietly, of course) that the toggling between on and off appears seamless. Additionally, by varying the ratio of how long the pin is on to how long it is off in each cycle, we can simulate varying voltages between zero voltage and the maximum ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access