I'd like to find a hardware-based solution to make LEDs fade from digital pins. i.e. instead of switching on/off, slowly fading (500ms) into/out of full brightness. I can't imagine a small capacitor taking half a second to discharge... Ideally it would be in a nice DIP16 package so I can get an array of fading LEDs. Does my dream component exist?
The usual way to do this is to use PWM (Pulse Width Modulation)
Just about any modern microcontroller has a PWM peripheral that can be set up for this purpose. If you don't want to use a microcontroller, a dedicated PWM IC or a timer IC like the ubiquitous 555 can be used.
The process is simple, the pulse frequency is set fast enough so the human eye cannot detect flicker (typically above 25Hz - see Persistence Of Vision) and the time on vs time off is varied from 100% on (full brightness) through 50% on 50% off (half brightness) to 0% on (off)
Check on the 'net for "555 LED Fade" and you should get plenty of results. Here's one picked at random from here ( I haven't checked it so I can't confirm it works correctly) :
Alternatively, if absolute accuracy of timing is not so important, a simple option would be to use an RC filter and transistor switch. This way the cap doesn't have to supply the LED current, only the base current. Something like this:
Any general purpose NPN should do, and you can tweak the R and C values to suit.
This option can easily be extended to an current mirror array with the addition of an opamp. This circuit should perform well as long as the transistors are all of the same type (supply used is +5V):
If you have a high enough supply voltage, the LEDs can go in series like this (supply used here is +10V):
Alternatively, if you have a low supply voltage but want to drive the LEDs in series, there are lots of cheap boost ICs such as the CAT4238. This part can dim the LEDS using PWM or a varying DC voltage (details are in the datasheet)
The FAN5646 is a flexible and compact solution for a blinking/fading LED.
You could use a small cap + big resistor to generate a nice long charge characteristic (t=RC), then feed that into the base of a transistor and drive the LED from there.
This allows for a bigger resistance since the current through the LED isn't limited by the resistor size, and then you can use a small cap.
It would be necessary to bias the transistor so that it's being used as an amplifier (if it hits saturation, then the LED will just stay on).
If by a digital pin you are using an output from some type of processor, it is possible to change the brightness in firmware. As you change the duty cycle of the pin, the eye acts like a filter and perceives a shorter on time as a dimming in brightness.
1 - Use a PWM pin output instead of a digital GPIO pins. By changing a few registers you can change the on time of the LED and thus the brightness.
2 - Use a timer (polled or interrupt) to change the state of your pin.
3 - Use external shift register ICs to latch the on/off times of n LEDs. Though this requires more programming effort, it is extensible and uses fewer GPIO pins than (1) and (2).
PWM LED Drivers. They need configuration from a microcontroller though. 555 Timer + a few resistors and caps can do the same, no software needed.
protected by W5VO♦ Feb 20 '13 at 4:25
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.
Would you like to answer one of these unanswered questions instead?