Using PWM to generate analog values

Pulse width modulation, known as PWM, is a technique that makes it possible to generate an analog result with digital means through the usage of a digital on-off pattern. The pins that provide PWM capabilities use a digital control to create a square wave and it can simulate voltages between the configured IOREF voltage (5V in the default board configuration) and 0V by controlling the amount of time that the signal spends in the ON status (IOREF voltage) and the time the signal spends in the OFF status (0V). The pulse width is the duration of the signal in the ON status (IOREF voltage), and therefore, pulse width modulation means changing the pulse width to get perceived analog values.

When you repeat the signal ...

Get Internet of Things with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.