# [SOLVED] Capacitor value for LED fading

I want to build a simple project where I dim an LED on a 4 second interval. I want the LED to slowly fade out each time its off in the loop. So I thought of connecting a capacitor in series before the LED so it's charge will make the LED fade out.

The LED is a usual 5mm green one, 20mA and 3.0V I guess.
Power source is 3x AA batteries, and I also have used a 100 Ohm resistor to protect the LED.

What type of capacitor should I use and what value? is there any other easy way?
I want the fade effect to last approximately between 1 and 1.5 second.?

You need the capacitor in parallel with the LED since it becomes the source of power once you switch off the circuit. You'll need an electrolytic rated to at least 12 volts. Specifying an optimum capacitance is a bit hit-and-miss since it all depends on the characteristics of the particular LED and on what you perceive as to be a suitable fade. I suggest you experiment by buying a couple of capacitors, say 100uF and 1000uf, try each one, time the fade time and then determine what actual value you need to suit your application. Note that you will also need an extra current limiting resistor in series with the capacitor. The one from your arduino will not suffice.

jackrae:
You need the capacitor in parallel with the LED since it becomes the source of power once you switch off the circuit. You'll need an electrolytic rated to at least 12 volts. Specifying an optimum capacitance is a bit hit-and-miss since it all depends on the characteristics of the particular LED and on what you perceive as to be a suitable fade. I suggest you experiment by buying a couple of capacitors, say 100uF and 1000uf, try each one, time the fade time and then determine what actual value you need to suit your application. Note that you will also need an extra current limiting resistor in series with the capacitor. The one from your arduino will not suffice.

so i will buy electrolytic caps of 100, 220. 470, and 1000 and try them out, but Parallel? how

There are only two ways to put an LED and capacitor in parallel, and only one of them will have
the right polarity. +ve side of cap to LED anode.

On reflection the circuit requirement is slightly more complicated that first envisaged. The capacitor positive end should be connected to the supply end of the LED control resistor (not the LED anode) and should itself have a series resistor to limit charge current from the voltage source, say 47 ohms. The capacitor will then charge to supply voltage and be better capable of delivering what is intended.

Maybe - you can try either way.

You don't need a cap at all. Use a PWM output from the arduino (don't forget current limit resistor).
After its turned on, use millis() and control the PWM value being used.
analogWrite uses values from 0 to 255, so you could start at 250, 100mS later drop to 225, 100mS later drop to 200, etc down to 0 after 1000mS.

You don't need a cap at all. Use a PWM output from the arduino (don't forget current limit resistor).
After its turned on, use millis() and control the PWM value being used.
analogWrite uses values from 0 to 255, so you could start at 250, 100mS later drop to 225, 100mS later drop to 200, etc down to 0 after 1000mS.

no the arduino is only going to send a wireless signal to a module which will light the led.

@jackrae, if possible can you show a simple diagram?

I'm with CrossRoads... Is there any reason why you can't not fade the [u]usual way[/u] (in software with PWM)?

no the arduino is only going to send a wireless signal to a module which will light the led.

Then you need to tell us what module, post a link to it or a schematic of it. Only then can we see if the current capabilities will not be over rated.

Wireless needs some smarts on both ends to send and receive the signal.
The receiver can create the PWM signal, either in hardware, or fake it in software.

Grumpy_Mike:
Then you need to tell us what module, post a link to it or a schematic of it. Only then can we see if the current capabilities will not be over rated.

its a a simple wireless relay module, but I need to test the LED setup before I apply it to the project. thats why I wanted to know.

its a a simple wireless relay module,

No such thing, they are all complex. Now which one?

Thanks,
Now what sort of LED are you fading and what time do you want it to fade over?
What voltages have you available to power this LED?
Any fade with capacitors will be rapid between looking full on and looking off.

Grumpy_Mike:
Thanks,
Now what sort of LED are you fading and what time do you want it to fade over?
What voltages have you available to power this LED?
Any fade with capacitors will be rapid between looking full on and looking off.

I use the usual 5mm(straw hat?) one, green, 3v, 20mA.
I was planing to use 3 or 4 AA batteries. 1.5v each (not NiMH), if thats not good then I can use cr2032 cells.
Thats bad, I need a noticeably amount of fade.

This is what I intend to achieve- (3:05) - LED Blinking Firefly! - YouTube
but without the glow in the dark powder or UV led.

Edit-
I saw a video with capacitor, but cant figure out how he did it? Simple Capacitor and LED circuit - YouTube

I saw a video with capacitor, but cant figure out how he did it?

Jackrae said - Note that you will also need an extra current limiting resistor in series with the capacitor.
but this circuit only has one?

and shouldnt the resistor be connected to anode of led?
and why a 4.7K ohm resistor, shouldnt a 400 ohm do the job for 9v battery?

The capacitor series resistor was mooted when we thought your power source was an Arduino pin.

The current limiting resistor can be either side of an LED it doesn't matter. If you think it matters then you don't understand electricity.

The value of 4K7 is to make the glow of the LED last longer by not using all the current at once.

Grumpy_Mike:
The capacitor series resistor was mooted when we thought your power source was an Arduino pin.

The current limiting resistor can be either side of an LED it doesn't matter. If you think it matters then you don't understand electricity.

The value of 4K7 is to make the glow of the LED last longer by not using all the current at once.

Ok.

4K7 - the value of capacitor or resistor? why they are both 4.7K? does both have to be same value?