DIM a LED
Archiver
Posts: 46,084
Hi.....
I am new in BS2,
What is the best way to DIM a LED?
Tank you,
Edson
I am new in BS2,
What is the best way to DIM a LED?
Tank you,
Edson
Comments
h40miami@y... writes:
> Hi.....
>
> I am new in BS2,
>
> What is the best way to DIM a LED?
>
>
> Tank you,
>
> Edson
>
If you want the LED to run at 1 dim setting, the method to make it dim is to
increase the size of the resistor in series with the LED. To vary the
brightness. If you want variable dimming, use PWM.
1 dim setting....
To select an appropriate resistor, you generally do the following:
Generally to run an LED at "normal" brightness, you will want about 20ma
through the LED. This is VERY general and will vary depending on the LED.
The current through an LED is set by the voltage that will be supplied to the
LED AND a the value of a SERIES resistor.
If for example, you want 20 ma through the LED and the voltage source is 5
volts do the following
1) subtract the LED forward voltage from the supply voltage. The forward
voltage is GENERALLY 1.7 to 2.3 volts, and it varies on the LED and how much
current you put through it. As a starting point, say 2 volts is the forward
voltage.
If your supply voltage is 5 volts, 2 from 5 leaves 3 volts.
2) Using ohms law, select a resistor that will yield 20 ma with 3 volts.....
3volts / 20 mA = 150 ohms
For half the current (and a dimmer led) put 10 mA through the LED
3 volts / 10 mA = 300 ohms
These are simply starting values. A calculator really isn't needed. If your
supply is 5 volts, start with about 270 ohms, if the led is too bright for your
taste, simply increase the amount of resistance until you get the desired
level of dimming.
If you want to vary the brightness of the LED typically you will use PWM
(pulse width modulation). This is where you send a pulsing signal to the LED at
a
specific frequency (40 to 100 hz will work) and vary the "high" time or "low"
time of the pulse depening if you are sourcing (sending voltage to) or sinking
(grounding) the LED circuit.......
Ken
[noparse][[/noparse]Non-text portions of this message have been removed]
off-time of the LED -- that's what people are
talking about when they say 'PWM'.
If an LED has 20 mA through it (set by the
current limiting resistor), then if you put
a 200 uS on / 200 uS off square wave through it,
you should get a 50% dimmer LED. The BS2
should be able to cycle this fast.
You'll have to experiment with the numbers to
see at what point you see a 'flickering' LED,
instead of a dim one.
--- In basicstamps@yahoogroups.com, "h40miami" <h40miami@y...> wrote:
> Hi.....
>
> I am new in BS2,
>
> What is the best way to DIM a LED?
>
>
> Tank you,
>
> Edson
allan.lane@h... writes:
> You'll have to experiment with the numbers to
> see at what point you see a 'flickering' LED,
> instead of a dim one.
The cut off point to notice flickering is about 35 hertz (try it!).
Above 40 hertz, I, nor anybody I know has been able to see flickering.
[noparse][[/noparse]Non-text portions of this message have been removed]
wrote:
> The best way is to vary the on-time and
> off-time of the LED -- that's what people are
> talking about when they say 'PWM'.
>
> If an LED has 20 mA through it (set by the
> current limiting resistor), then if you put
> a 200 uS on / 200 uS off square wave through it,
> you should get a 50% dimmer LED. The BS2
> should be able to cycle this fast.
>
> You'll have to experiment with the numbers to
> see at what point you see a 'flickering' LED,
> instead of a dim one.
And if you wanna play, you can pump 50mA thru it if you pulse it. it
never gets hot enough to blow, but it shines really bright.
if you plan on trying that, keep the on time fixed and vary of the
off time. that way, when you get running slooow, it doen't get hot at
one long pulse and blow.
But play with it and have fun.
Dave
wrote:
> --- In basicstamps@yahoogroups.com, "Allan Lane" <allan.lane@h...>
> wrote:
> > The best way is to vary the on-time and
> > off-time of the LED -- that's what people are
> > talking about when they say 'PWM'.
> >
> > If an LED has 20 mA through it (set by the
> > current limiting resistor), then if you put
> > a 200 uS on / 200 uS off square wave through it,
> > you should get a 50% dimmer LED. The BS2
> > should be able to cycle this fast.
> >
> > You'll have to experiment with the numbers to
> > see at what point you see a 'flickering' LED,
> > instead of a dim one.
>
>
> And if you wanna play, you can pump 50mA thru it if you pulse it.
it
> never gets hot enough to blow, but it shines really bright.
>
> if you plan on trying that, keep the on time fixed and vary of the
> off time. that way, when you get running slooow, it doen't get hot
at
> one long pulse and blow.
>
> But play with it and have fun.
>
>
> Dave
op's I should have said you can pump 100mA, and that the 50/50 duty
cycle needs to be over 100hz (lower limit) for the thermal time
constant of she'll pop.
If you use some value like 150hz, you'll be safe and if you leave the
ON pulse time the same and extend the off pulse, you'll get dimming.
Dave
Going to 5V to OV in a Output Pin.
How can I do that using PWM?
Tahnk you,
Edson
enough it will allow your code time to do a few
other things during the process.
From: "h40miami" <h40miami@
> I am try to do a Automatic LED dim
> Going to 5V to OV in a Output Pin.
>
> How can I do that using PWM?
>
> Tahnk you,
>
>
> Edson
> I am try to do a Automatic LED dim
> Going to 5V to OV in a Output Pin.
>
> How can I do that using PWM?
>
> Tahnk you,
>
>
> Edson
Check the manual for how to do the PWM.
very clear and easier to study that than for us to post.
Dave
>Going to 5V to OV in a Output Pin.
>How can I do that using PWM?
>Tahnk you,
>Edson
Maybe something like this, which dims the led from full to off in a
few seconds.
' P0---/\/\--->|---Vss
' 220ohm led
i var byte
DO
for i=255 to 0
PWM 0,i,5
next
LOOP ' do it again
The above hovers longer at the brighter level. To get a more linear
appearing effect, dim using a power law, like,
DO
I=255
DO
PWM 0,i,25
i = i* 7/8
next
LOOP UNTIL X=0
LOOP
> DO
> I=255
> DO
> PWM 0,i,25
> i = i* 7/8
> ' next <--- no next here!
> LOOP UNTIL i=0 '<-- until i=0
> LOOP
bub in I= 255
IS anything wrong?
Thank you
--- Tracy Allen <tracy@e...> wrote:
> >I am try to do a Automatic LED dim
> >Going to 5V to OV in a Output Pin.
> >How can I do that using PWM?
> >Tahnk you,
> >Edson
>
> Maybe something like this, which dims the led from
> full to off in a
> few seconds.
> ' P0---/\/\--->|---Vss
> ' 220ohm led
>
> i var byte
> DO
> for i=255 to 0
> PWM 0,i,5
> next
> LOOP ' do it again
>
> The above hovers longer at the brighter level. To
> get a more linear
> appearing effect, dim using a power law, like,
>
> DO
> I=255
> DO
> PWM 0,i,25
> i = i* 7/8
> next
> LOOP UNTIL X=0
> LOOP
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed.
> Text in the Subject and Body of the message will be
> ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
>bub in I= 255
>
>IS anything wrong?
Well, it is a snippet and variable "I" needs to be declared, and a
couple of typos corrected, and it uses PBASIC 2.5 syntax:
' {$PBASIC 2.5}
' P0---/\/\
>|---Vss
' 220ohm led
' power law intensity rolloff...
i var byte
DO
I=255
DO
PWM 0,i,25
i = i* 7/8
LOOP UNTIL i=0
LOOP
>
>Thank you
>--- Tracy Allen <tracy@e...> wrote:
>> >I am try to do a Automatic LED dim
>> >Going to 5V to OV in a Output Pin.
>> >How can I do that using PWM?
>> >Tahnk you,
>> >Edson
>>
>> Maybe something like this, which dims the led from
>> full to off in a
>> few seconds.
> > ' P0---/\/\--->|---Vss
>> ' 220ohm led
>>
>> i var byte
> > DO
>> for i=255 to 0
>> PWM 0,i,5
>> next
>> LOOP ' do it again
>>
>> The above hovers longer at the brighter level. To
>> get a more linear
>> appearing effect, dim using a power law, like,
>>
>
> > DO
>> I=255
>> DO
>> PWM 0,i,25
>> i = i* 7/8
>> next
>> LOOP UNTIL X=0
> > LOOP
>>
>>
>>
>> To UNSUBSCRIBE, just send mail to:
>> basicstamps-unsubscribe@yahoogroups.com
>> from the same email address that you subscribed.
>> Text in the Subject and Body of the message will be
>> ignored.
>>
>>
>> Your use of Yahoo! Groups is subject to
>> http://docs.yahoo.com/info/terms/
>>
>>
>
>
>__________________________________
>Do you Yahoo!?
>Yahoo! SiteBuilder - Free, easy-to-use web site design software
>http://sitebuilder.yahoo.com
>
>To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
>from the same email address that you subscribed. Text in the
>Subject and Body of the message will be ignored.
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Sorry for question, I am new in BS2
--- Tracy Allen <tracy@e...> wrote:
> >Hy, The First Exemplo works but the second one has
> a
> >bub in I= 255
> >
> >IS anything wrong?
>
>
> Well, it is a snippet and variable "I" needs to be
> declared, and a
> couple of typos corrected, and it uses PBASIC 2.5
> syntax:
>
> ' {$PBASIC 2.5}
> ' P0---/\/\
>|---Vss
> ' 220ohm led
> ' power law intensity rolloff...
> i var byte
> DO
> I=255
> DO
> PWM 0,i,25
> i = i* 7/8
> LOOP UNTIL i=0
> LOOP
>
> >
> >Thank you
> >--- Tracy Allen <tracy@e...> wrote:
> >> >I am try to do a Automatic LED dim
> >> >Going to 5V to OV in a Output Pin.
> >> >How can I do that using PWM?
> >> >Tahnk you,
> >> >Edson
> >>
> >> Maybe something like this, which dims the led
> from
> >> full to off in a
> >> few seconds.
> > > ' P0---/\/\--->|---Vss
> >> ' 220ohm led
> >>
> >> i var byte
> > > DO
> >> for i=255 to 0
> >> PWM 0,i,5
> >> next
> >> LOOP ' do it again
> >>
> >> The above hovers longer at the brighter level.
> To
> >> get a more linear
> >> appearing effect, dim using a power law, like,
> >>
> >
> > > DO
> >> I=255
> >> DO
> >> PWM 0,i,25
> >> i = i* 7/8
> >> next
> >> LOOP UNTIL X=0
> > > LOOP
> >>
> >>
> >>
> >> To UNSUBSCRIBE, just send mail to:
> >> basicstamps-unsubscribe@yahoogroups.com
> >> from the same email address that you subscribed.
> >> Text in the Subject and Body of the message will
> be
> >> ignored.
> >>
> >>
> >> Your use of Yahoo! Groups is subject to
> >> http://docs.yahoo.com/info/terms/
> >>
> >>
> >
> >
> >__________________________________
> >Do you Yahoo!?
> >Yahoo! SiteBuilder - Free, easy-to-use web site
> design software
> >http://sitebuilder.yahoo.com
> >
> >To UNSUBSCRIBE, just send mail to:
> > basicstamps-unsubscribe@yahoogroups.com
> >from the same email address that you subscribed.
> Text in the
> >Subject and Body of the message will be ignored.
> >
> >
> >Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed.
> Text in the Subject and Body of the message will be
> ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com