Posts Tagged ‘pwm’

Controlling the Brightness of an LED (Using PWM)

Monday, June 22nd, 2009

It is easy to use a microcontroller to turn LEDs on and off in almost any pattern you want. (Click here for more information.) But you can only turn the LED on and off. So what if you want to control the brightness of the LED? The same problem comes up in robotics where you want to control the speed of a motor with a microcontroller. It is not good enough to just turn the motor on and off. To control the brightness of the LED or speed of the motor you have to control the amount of current going through the device. But how? One solution that may occur to you is to quickly turn the LED or motor on and off. The current only flows when the output is low (for microcontrollers LED circuits are usually wired so current flows into the microcontroller when the output is low, as shown in the tutorial at http://www.iguanalabs.com/1st2051.htm). The output of your microcontroller will look like the following square wave. (more…)