What is PWM and how it works

Pulse Width Modulation (PWM) is a technique for getting analog results with digital means. Digital control is used to create a square wave, a signal switched between ON and OFF. If you repeat this on/off pattern fast enough with a LED for example, the result is as if the signal is a steady voltage between 0 and VCC controlling the brightness of the LED.