Microcontroller › 8051 › STREET LIGHT THAT GLOWS ON DETECTING VEHICLE MOVEMENT › very goodPWM gives variable
very good
PWM gives variable DC output. the equation for PWM output is
Vcc * Ton / Ttotal
for example if Ton is 50% of Ttotal then output is Vcc / 2
similarly if Ton is 25% – output is Vcc / 4 like wise
so avg DC output varies as pulse width varies.
if this voltage is applied to LED (any DC operated device) its intensity varies.
generating PWM is very simple. if your controller does not have built in PWM channel then you can do this
take two time variables Ton and Toff.
make one delay subroutine that gives delay as per value passed of Ton or Toff
set any one pin of microcontroller to 1
give delay for Ton time
reset that pin to 0
give delay for Toff time
now just change Ton and Toff values like to increase pulse width increase Ton and same time decrease Toff by same value e.g. Ton+=5 and Toff-=5;