PWM is a very useful tool in electronics. From changing the brightness of a light bulb to changing the speed of a motor, PWM is the key to success.
PWM works by creating a square wave with a duty cycle that changes how often the signal is high.
Let's say we want to have an LED at half brightness. Dimming by changing the voltage would simply not work. Brightness is not proportional to voltage. Instead, we can have the LED on for half the time. This is PWM. The signal, in this case, would look like this -->
Because of the way our eyes work, when a light turns off, we see the light fade off quickly. This is why PWM works–the brightness equals out, making us see a non-flickering light.
When making projects with micro-controllers, you may want to use PWM. With Arduino-compatible boards, you can use
analogWrite();
to make PWM. The parameters are
analogWrite(pin#, dutyCycle);
with "pin#" being the pin number. The pin must be PWM-compatible, marked with a tilde wave (~). "dutyCycle" refers to a number ranging from 0 (completely off) to 255 (completely on).
Comments