This will describe a simple circuit for allowing a 9 v. battery to power an LED, and then fade out once the pushbutton is released. Something very similar was requested in a question on the forums somewhere. I hope this is useful as a prototype, or in inspiring ideas on how to use this set up.
Step 1: Parts
Here is an inventory of the parts I used:
Q1: most any SS (small signal) NPN transistor will do here.
C1: 100-330 uF electrolytic polarized capacitor
D1: I used a Rainbow flashing LED (so this circuit will flash), if a regular LED is used, it will not flash.
R1: a 10k resistor (carbon, 1/4 w is fine).
For R1, I used a 1 K resistor in series with a 10K potentiometer, for adjustment purposes.
PB: a normally open (N/O) push button switch
Misc.: wire, pc board (or prototype board), 9 v battery snap (and battery), desired case design
Step 2: Assembly.
Here are the steps to complete this project:
Since the schematic is REALLY straightforward, I simply soldered everything in as I had drawn it, except for the PB, the LED, and the Pot.
The PB switch, the LED and the pot., I soldered onto a little extra wire so I could mount them on holes and a slot I had cut into the box. My box was a small cassette style dust cover for backup tapes that were discarded where I work. They make VERY easy to work with cases, and yet are very sturdy.
Looking at the Schematic, and after aquiring my transistor (and consulting a pin out sheet), I found that my transistor was set up (looking at the bottom, with the flat side up) Emitter, base, collector (E, B, C on the schematic). Using a set of hemostats as a heat sink, I soldered in the transistor on one end of the PC board. If you feel uneasy about this, three pin transistor sockets are available from some suppiers (this makes for easy changing of the transistor if need be without soldering).
I ran one wire from the transistor's (E)mitter to the spot on the other end of my PC board that would connect to the ground of the Power supply. To this, I then soldered the negative pin (marked with a - sign) of C1. The positive pin (normally unmarked) was soldered into the board, and then I soldered in R1. R1 was run from the capacitor to the (B)ase of the transistor.
At the joint between R1 and C1, I soldered a wire that would eventually be soldered to one pin of the push button (PB) switch. The other side of that switch (the other pin) was then soldered to the + input from the battery AND to the positive side of the LED. The other pin of the LED is then soldered to another wire that is then soldered to the (C)ollector pin of the transistor.
Step 3: Final Testing and Adjustments
The first time I fired it up, it didn't work. I tried several things....but nothing was lighting the LED.
Then I decided to measure the voltage across the LED and well there's your problem right there!, no voltage across the LED.
Tracing back through the soldering joints, I found one place where there was nearly a hairline break in the solder. Bridging that gap fixed the problem.
Step 4: Let's Box It Up ...
Here I went a bit cheap and found a "non-slip surface pattern to alter for my case (well, the print out of it on paper anyways).
After accentuating certain portions of it, I printed it out, and cut it with a scissors to fit.
I also took and carefully placed a small smear of glue behind each raised bump" (to have it soak into the paper a bit, thus raising that "bump"; making it aesthetically appealing.
It doesn't do much, but it has a lot of potential...IMHO.