Arduino PWM (Pulse Width Modulation)
The PWM (Pulse Width Modulation) is a technique to generate controlled analog signal using variable-width digital signal. Digital control is used to generate square wave signal by switching on and off. This on-off pattern can simulate voltages in between the full Vcc and off (0 Volts) by changing the portion of the ON time the signal spends on versus the time that the signal spends off. The duration of "on time" is called the pulse width. User can change pulse width to get varying analog signal. If user repeat this on-off pattern fast enough and feed signal to an LED then the result is as if the signal is a steady voltage between 0 and Vcc controlling the brightness of the LED.
The common use of PWM pins includes controlling LED brightness, DC Motor speed, voltage regulation, audio signal generation, servo motor, etc.
Duty Cycle -
The duty cycle of the PWM pulse is shown below:
th: It is the duration of the signal when the signal is HIGH.
tc: It is the total duration of the signal as the sum of HIGH and LOW.
Duty cycle = th/tc
The duty cycle is the ratio of the pulse width to the total width of a signal.