# led fading in and fading out

#### ineedhelp

Joined Mar 3, 2006
1
i want to make a led fade in and out how would i do this ?

#### jatulm

Joined Feb 13, 2006
7
There are many ways of doing that. But basically you would need an oscilator connected as the source of you led... of course, you would need a resistor beteween the source and the led in order to NOT burn the LED....

I mean:

SOURCE ----> /\/\/\/\/\ - -D|------ GND

where /\/\/\ is the resistor and -D| is the LED (long life to ASCII drawing heh)

What is a LED?

Light Emiting Diode ... this means that when a current 'I' passes through the LED from "left to right" in my drawing, the the LED is essencially a short circuit (very low resistance) and emmits light. When the LED is polarized "backwards", a current 'I' would try to pass through the LED but it would be essencially an open circuit (very high resistance) and no current will exist (actually there is a very very low current).
Thats why you need the resistor.. otherway you would have almost a shortcircuit between source and gnd, and you would probably see light due to the fire, heh..

The oscilator, acting as the Source, would give a voltage between +V and -V as a sinusoide. so, when the source has a voltage greater than 0V (GND) then current will pass trhough the LED and it will emmit light, the smaller the voltage of the source, the smaller the current and the weaker the ligh will be.
When the source has a voltage under 0V (GND) then no current will pass through the circuit as I explained before.

Therefore, you have a led that emmits light fading in and out, and have a half period of completly OFF.
If you want to avoid the fact that it is OFF for a while, then you would need at the output of the source a FULL-WAVE rectificator bridge. (google for it)

greetings

Originally posted by ineedhelp@Mar 3 2006, 09:45 AM
i want to make a led fade in and out how would i do this ?
[post=14570]Quoted post[/post]​

#### Papabravo

Joined Feb 24, 2006
21,225
Originally posted by jatulm@Mar 3 2006, 11:00 AM

SOURCE ----> /\/\/\/\/\ - -D|------ GND

where /\/\/\ is the resistor and -D| is the LED (long life to ASCII drawing heh)

[post=14571]Quoted post[/post]​
The SOURCE in the above drawing, by the previous poster, could also be a pulse width modulated (PWM)signal. With a very narrow positve going pulse, the LED would be off most of the time. As you increase the duty cycle(ratio of on time to off time) the average voltage of the on and off periods will approach the threshold of the LED and it will begin to glow dimly. As the duty cycle continues to increase the LED gets brighter until the duty cycle is 100% and the LED is on all the time. The basic frequency of the PWM should be in the 500Hz to 3kHz range, but the rate at which you increase and decrese the duty cycle will be much slower in the 0.25 to 10 Hz range.

#### Mazaag

Joined Oct 23, 2004
255
Bout the PWM, if you want it to happen automatically, then you need something ( like a microcontroller probably) that will change the duty cycle of the pulses automatically.

#### Papabravo

Joined Feb 24, 2006
21,225
Originally posted by Mazaag@Mar 3 2006, 03:38 PM
Bout the PWM, if you want it to happen automatically, then you need something ( like a microcontroller probably) that will change the duty cycle of the pulses automatically.
[post=14581]Quoted post[/post]​
Quite correct. The original question was an open ended, "how would I do this" sort of question with no criteria for evaluating solutions. In the interest of completeness I advanced an alternative. It is up to the original questioner to evaluate the alternatives for his particular situation about which we know very little, or refine his requirements.

#### pebe

Joined Oct 11, 2004
626
Originally posted by ineedhelp@Mar 3 2006, 02:45 PM
i want to make a led fade in and out how would i do this ?
[post=14570]Quoted post[/post]​
If you just want to make a LED dim at the twiddle of a knob. then here's a simple variable mark/space ratio generator built with a 555 timer.

The cap C! has different charge and discharge paths via D1 and D2 so by varying the position of P1 you can go from full brightness to darkness.

#### hgmjr

Joined Jan 28, 2005
9,027
I agree with those responders that have recommended a Pulse Width Modulation (PWM) scheme as the solution of choice.

hgmjr

#### windoze killa

Joined Feb 23, 2006
605
Originally posted by Mazaag@Mar 4 2006, 06:38 AM
Bout the PWM, if you want it to happen automatically, then you need something ( like a microcontroller probably) that will change the duty cycle of the pulses automatically.
[post=14581]Quoted post[/post]​
Microcontroller????? What ever happened to the humble 555?

#### thingmaker3

Joined May 16, 2005
5,083
In Pebe's drawing, one could substitute an oscillator for P1. Sawtooth or sine-wave would make for fade-in & fade-out.

Joined Jan 10, 2006
614
Or, if you wanna stay linear, then just drive it with a slow buffered sawtooth.
(PWM would be my choice though).

#### pebe

Joined Oct 11, 2004
626
Originally posted by thingmaker3@Mar 5 2006, 05:57 AM
In Pebe's drawing, one could substitute an oscillator for P1. Sawtooth or sine-wave would make for fade-in & fade-out.
[post=14676]Quoted post[/post]​
But the circuit IS an oscillator. The output is a square wave with a variable mark/space ratio - PWM if you like.

#### thingmaker3

Joined May 16, 2005
5,083
Indeed. I should have said "second oscillator."

#### Mazaag

Joined Oct 23, 2004
255
Originally posted by windoze killa@Mar 3 2006, 07:17 PM
Microcontroller????? What ever happened to the humble 555?
[post=14612]Quoted post[/post]​

Haha. Humble 555 all the way