Electronic – How to make a component only be on when a capacitor powers it

capacitor

I've been thinking and thinking about this.

Look at this image:

enter image description here

(Imagine both the resistor and LEd were in parallel with the capacitor, otherwise the LED will be overloaded)

By doing this I've managed to create a circuit that, when it loses power, makes the LED fade.
However, I wanted to find a way in which the LED will only be powered when the circuit doesn't have a power supply (other than the capacitor). I've been thinking about logic gates, diodes, etc., but can't figure out a way in which it would work. Is there any?

Best Answer

You need a way to differentiate between "powered from an external source" and "powered from capacitor only" -- a transistor, diode and a pair of resistors can do this for you.

schematic

The PNP transistor will remain off for as long as 12V is present. The diode allows the capacitor to charge but prevents the capacitor voltage from feeding the base of the transistor. R1 is a weak pull-down which turns the transistor on when the stronger pull-up R2 has no source voltage.