Introduction: How to (Not) Hack a Night Light

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;

How To Hack Together An Adjustable, Dark Activated, AC Outlet Powered, Cold Cathode Tube, Night Light

Step 1: Gather Parts and Accessories

See that Modware - Windowed Side Panel and Mod Kit over in the corner? We bought that a few years ago in the heyday of the PC case modding fad and never used it. Time to wipe the dust off. Take out the 12" Neon Cold Cathode Light Kit and the Case Cutting Tool, throw the rest away. The cathode kit includes the light tube itself and a voltage converter (black box thingy). We won't be using the cutting tool in this project but you never know when you'll need some crappy tin snips.

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

When sizing a power source it would do you good to ask the load a few questions. What's your current draw? What's your favorite potential? Are you always this needy or do you spike at all?

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

Just to test things out a bit, strip the AC adapter's wires and stuff them into the cold cathode connector. Make all the proper safety checks and plug it in.

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

The main goal here is to electronically switch on/off the light according to ambient luminescence. Maybe the simplest switching circuit is a transistor and resistors for biasing. Make one of those resistors sensitive to light, and viola, diagram 1. Vcc is the DC voltage from your wall adapter and Load is the cold cathode. R1 and R2 could/should be a potentiometer in series with a regular resistor. Its up to you if you want to use an NPN or PNP transistor.

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

Head on down to your local Radio Shack and pick up the MPF102 JFET. Go ahead and just substitute the old transistor with the JFET. Remember, Base = Gate, Collector = Drain, Emitter = Source.... kind of.... not really.... just line them up the same in the circuit. Turn on the power.

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.

Mmmm, smokey.

Step 6: Control Circuit: Final Attempt

Time again for a Radio Shack run. Your shopping list is now:

From Mouser:
Five MOSFETs because shipping would be the same for a single and extras might come in handy.

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!

Measure the empty space inside your AC adapter (hopefully there is some). Cut out a chunk of PCB a little bit larger than the width and depth of the empty space. It needs to fit snug and it's a good idea to shave it down slowly instead of starting over with a new board. Arrange the control circuit in such a way that the photoresistor and trimmer are close to the edges. Solder your heart out.

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

Adding up all the parts and stupidity, this project cost me $46.95. I could have bought an awesome GE Limelite Night Light for $4.19. It uses space age materials!

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!