Pulse Width Modulation (PWM) is a technique widely used in modern switching circuit to control the amount of power given to the electrical device. This method simply switches ON and OFF the power supplied to the electrical device rapidly. The average amount of energy received by the electrical device is corresponding to the ON and OFF period (duty cycle); therefore by varying the ON period i.e. longer or shorter, we could easily control the amount of energy received by the electrical device. The Light Emitting Diode (LED) will respond to this pulse by dimming or brighten its light while the electrical motor will respond to this pulse by turning its rotor slow or fast.
Working with Atmel AVR Microcontroller Basic Pulse Width Modulation (PWM) Peripheral – [Link]