The road to hacker prowess is paved in stillborn experiments and bloody pieces of failed projects. From these failures we learn patience, determination, how to cuss, and of course, what not to do. The following hour of programming details one such disaster;
Step 1: Gather Parts and Accessories
Rummage through your junk box/drawer/closet/basement and find a suitable AC adapter. We'll go into how to pick the right adapter a little later.
Also in said junk, find a transistor, a potentiometer, resistors, and a photoresistor. Don't get too caught up in the values, I have a feeling we'll be replacing these with Radio Shack parts soon anyway.
Step 2: Sizing the AC Adapter
Take a look at how our cathode kit is supposed to connect to the computer. It's a standard 4-pin peripheral plug but it only has two wires. Is it +12v or +5v? See where the two wires line up when you connect it to an open, and running, computer. Then, measure with a multimeter. Or just look up the color code on the internet. It's +12v.
Current is a little trickier. You have to place your multimeter in series. Use a 12 volt power supply and stuff the ground wire into the cathode kit's connector. Connect one lead of the meter to the power supply's positive and the other lead to the kit's connector. Approximately 333mA.
Ignore this new information and just grab the smallest AC adapter in your junk pile.
Step 3: Step It Up a Notch
Things are looking dim. And smelling hot.
Well, that adapter isn't going to work. It wasn't gonna have enough room inside for our control circuit anyway. Grab one that says it can handle the awesomeness of a blue cathode tube. We're not even gonna test it this time. That's confidence.
Step 4: Control Circuit: Attempt Number 1
Load this up on a prototyping board and let the electrons fly. Then, understand the meaning of 'In Between'.
There is a certain ambient brightness that will cause this circuit to be not quite on and not quite off. The cathode tube will probably be dim and blinky and may even make a buzzing noise. What we need is a circuit that will give us a hard "on".
Step 5: Control Circuit: Attempt Number 2
Wow, the light never turns off.
Some of our more learned viewers will have already figured out this attempt was doomed from the start. They know that the MPF102 is an N-Channel RF Amplifier and that the gate bias voltage should be negative for a fully off switch. That just won't do for our needs.
Some things you forget from college turn out to be important later.
Optional:Before finding out about the negative bias thing.
In frustration, try to set up a Darlington pair by combining the JFET and the transistor from Attempt Number 1. Reference diagram 2.
Step 6: Control Circuit: Final Attempt
- CdS Photoresistors (5-Pack) - $2.99
- 100-Piece 1/4-Watt Fixed Carbon-Film Resistor Assortment - $6.49
- 10K-Ohm 15-Turn Cermet Potentiometer/Trimmer - $2.69
- TL082/TL082CP Wide Dual JFET Input Op Amp (8-Pin DIP) - $1.99
- Grid-Style PC Board with 371 Holes - $1.99
- MOSFET - Enhancement Mode N-Channel 30V 1.2Ohm X 5 - $0.76 each, $5.00 s&h
The circuit in diagram 3 is what we're shooting for. The main plot point here is the voltage comparator created with the op-amp. The varying voltage from the photoresistor/trimmer divider gets compared to the constant voltage from the resistor divider. The output of the op-amp is a definitive "on/off". And, of coarse, the MOSFET is there to handle the switching of the light.
Throw this on a prototyping board first. You want to check functionality because of the wildly varied values of photoresistors. It would be tragic to get it all soldered together yet not have enough adjustment to get the light turning on in the dark.
Step 7: All Together Now!
We need a holy AC adapter. One hole for the photoresistor and one for the trimmer. There should already be a hole from the old wire where we can place the cold cathode tube wiring. It would be nice to have the photoresistor sticking out the front but some AC adapters have PC boards in the way. Instead, have it hang over the edge of the board so it will stick far enough through a side hole to catch some photons.
Line everything up and shove it all together now. If the circuit board is snug and the photoresistor is in a good position it shouldn't rattle around too much. If the adapter won't hold together use some rubber bands. Hopefully, you can get to the trimmer with a small screwdriver.
Don't panic! Be cautiously optimistic that everything is in order. Hook up the cold cathode tube kit and plug in the AC adapter to an appropriate AC wall outlet.
If there are sparks, you've failed. If the lights go out in the house, you've failed. If you've swept the trimmer up/down and the light doesn't turn on/off, you've failed. If it is off with the lights on and you see nice neon glow with the lights off, congratulations!
You now know how (not) to hack a night light!
Step 8: Why This Is a Failure
Even though the light draws less than half the rated power of the AC adapter, it still gets warm. I tried to remedy this with a lot of little venting holes to no avail. I'm still nervous to leave it plugged in over night.
Photoresistors are temperature sensitive. The on/off point of the device tends to drift with the aforementioned heat build-up. A possible fix I'm thinking about is to add a similar photoresistor to the trimmer side of the divider with black tape over it. That should negate the temperature variation of the first photoresistor.
There is an unused op-amp in the control circuit.
Hysteresis would be nice. There may or may not be room to build or place a Schmitt trigger. This would probably help out with the photoresistor drift, also.
In conclusion, and because I suck at conclusions, enjoy the glamour shots!