PWM signals
PWM is a way of handling analog write operations. It is a set of repetitive signal pulses, where the time of the pulse is in milliseconds, and the width of a pulse can be controlled using the write_analog()
operation. When an analog device is connected to the Micro:bit, the read operation can be performed using read_analog()
, and at the same time, when an output analog signal needs to be generated, it can be done using PWM. To do so, a duty cycle needs to be defined. The duty cycle can be explained as a measure of time in which a signal is active or a General Purpose Input/Output (GPIO) device receives an output. It can be easily understood with the help of this figure:
Figure 9.6 – PWM with the duty cycle (courtesy: https://microbit-micropython.readthedocs.io/_/downloads/hu/latest/pdf/)
In Figure 9.6, the first pulse indicates an equal distribution of high and low values; it implies that the output device connected to a particular pulse...