If you look at the output from the pins when you are sending analogue data with an oscilloscope, you'll see that the waveform alternates between 0v and 3.3v. This is because the analogue output uses Pulse Width Modulation (PWM).


This is so-called as the signal has pulses that repeat at a fixed rate, but the width of this pulse can be changed in code. It is a way of varying power by setting the duty cycle to a lower or higher amount which gives us an average between 0v and 3.3v.


The speed of the duty cycle (%) can be considered the portion of time that the signal is on (3.3v) compared to the time that it is off (0v)


PWM duty cycle

PWM Duty Cycle, courtesy of Kitronik Ltd



Modulating the width of the pulse allows us to control things like motors and LED brightness.


Further Information

PWM in micropython