Electronic – Simple circuit for fading an LED out (no MCU)


What is the simplest circuit you can create which fades an LED in from off to bright, without using any sort of processor or MCU? Would an inductor be of any use here?

Best Answer

Would an inductor be of any use here?

Yes! Just as a capacitor resists changes in voltage, an inductor resists changes in current. Since brightness is a function of current, if you change current slowly, you change brightness slowly. You could do this:


simulate this circuit – Schematic created using CircuitLab

Here R1 is just the usual current-limiting resistor, calculated just as usual. D2 is necessary so that when SW1 is opened, there is still a path for current to flow, so the LED can fade out.

Now, the defining function of an ideal inductor is:

$$ v(t) = L \frac{\mathrm di}{\mathrm dt} $$

In English, the voltage across the inductor is equal to the rate of change of current (in amperes per second) times the inductance (in henrys).

Now, say we wanted the LED to transition from on to off (or off to on) over the span of something like 1 second. We could solve that differential equation, but it's a bit of a pain because as the current through L1 increases, so does the current through R1. By Ohm's law, this means the voltage across R1 also increases, and since the voltage across D1, R1, and L1 in total must be 9V, more voltage across R1 means less voltage across L1.

Fortunately, just as with resistor-capacitor circuits, resistor-inductor circuits have a time constant. This is the time it takes the current to reach 63% of its final value (which is set by R1, which you probably picked to make the final current under 20 mA, according to your LED's specifications).

The time constant is simply the inductance times the resistance. At the expense of some accuracy, we are going to ignore the diode to simplify things. So let's say we want the LED to take something around 1s to transition. That means we need something on the order of:

$$ L_1 \cdot R_1 = 1\:\mathrm s $$

So if we want 15mA in our LED, R1 must be (again, approximations ignoring D1) on the order of \$ 9\:\mathrm V / 0.015\:\mathrm A = 600\:\Omega \$. Round up to the next standard value: 680Ω. So:

$$ L_1 \cdot 680\:\Omega = 1\:\mathrm s \\ L_1 = 1.47\:\mathrm{mH} $$

This is entirely feasible, but a good engineer knows that an inductor with that inductance, that won't saturate at 15mA of current, is big and expensive. Inductors are just generally a pain in the ass. It's neat that this circuit is simple entirely passive components, but even if we incorporate some active components, the end result will probably be cheaper if it means we can use capacitors instead.

Introducing: the gyrator. This is a neat concept that can do a lot of things, but a very common application and implementation is the simulated inductor. It takes a capacitor and makes it look like an inductor, like so:

gyrator equivalent circuit

We already calculated that we want \$R_L = 680\:\Omega\$ and \$L=1.47\:\mathrm{mH}\$, so we can solve for \$RC\$:

$$ 1.47\:\mathrm{mH} = (680\:\Omega) RC \\ RC = 2.16 \cdot 10^{-6} $$

We can pick any resistor and any capacitor such that their time constant is \$ 2.16 \cdot 10^{-6} \$. That gives us a lot of flexibility. It also means we don't even need a big electrolytic capacitor. We can use a cheap ceramic capacitor.

Let's just say, because we have a lot of them in our parts drawer, that we want \$ R = 10\:\Omega \$. Then:

$$ (10\:\Omega)C = 2.16 \cdot 10^{-6} \\ C = 216\:\mathrm{nF} $$

Let's round that to the nearest standard value of 220nF. So, the final circuit looks like this:


simulate this circuit

If you have an ideal op-amp, this circuit will function just the same as the inductor version above. The biggest problem you will have with a real op-amp is that their outputs can't go all the way to the supply rails. So, pick a rail-to-rail variety that can get at least close enough to the positive rail to turn the LED off. If it makes your op-amp selection easier, you can also move the LED to be on the output of the op-amp, then the op-amp has to get close to the negative rail to turn off the LED.

Really, this isn't an ideal solution, but hopefully it is at least educational. You can of course accomplish something like this simulated inductor with just about anything with gain, like a single BJT. In fact doing so may have some advantages: it may be simpler, and you may not run into the rail-to-rail issue. This circuit does give some insight into how an active device can make a capacitor look like an inductor through feedback. In fact, if you examine some of the other BJT solutions in other answers, they may have feedback configurations that are similar.