Building A PopSci LED Flashlight

October, 2008

Introduction

This web page documents how I built a PopSci DIY LED flashlight. I became interested in building one after looking at Brian Riley's Flashlight Kit. It is based on a stripped-down Dorkboard. Studying Brian's photos, assembly documentation, and the documentation available on a different website for building the Dorkboard convinced me to give the kit a try. This project continues my attempts to learn and master the Freeduino platform. At first, I thought it was rather silly to assemble a bunch of LEDs and stuff them into or on a flashlight body, but as I worked with the different materials I realized this project is a challenge. It is offering lessons I need to learn in circuit assembly and how to package a project. I will need to think carefully about the parts placement, how to mount them so they are easy to access and protected from most of the bumps and bruises a flashlight can take. How will I get the lantern's switch working for my needs? How will I access the Dorkboard in case I want to program it. And so on. What you are reading here is how these items were dealt with in a way that would produce a safe, usable, attractively packaged flashlight.


Flashlight Construction

The completed Dorkboard operating in a breadboarded test circuit. I put the circuit on a breadboard first to test that the components, so far, really work.

The steps that are needed to achieve a working PopSci LED flashlight are:

Brian provides a circuit schematic and documents how to assemble the Dorkboard for this project here. He discusses assembling the LEDs and getting started with a 6-volt lantern battery style flashlight here, further down on his ordering page, so I will not discuss some of these things. I highly recommend that you closely read his instructions. In fact, for my comments below to make sense, you need to study his assembly instructions first. Brian's site discusses mounting the Dorkboard on a PC board and shows the pinout needed. I am writing this web page under the assumption that you have followed his assembly instructions and are coming here to pick up my own additional details. You should have completed two steps at this point: first, you have built the Dorkboard and LED assembly and then breadboarded the circuit to verify it works. After verifying it works, you should have mounted the Dorkboard on the Radio Shack 276-148 PC board that Brian's site discusses. I will now show you how I installed the 2N7000 transistor, the 100 Ohm resistor and the 1N5819 diode to the PC board and test the circuit on the LEDs. Then I will show how I put all the components shown in the photo on left into the yellow flashlight body which is perched on the vise and got it working.


Project Goals

I have some goals for this project. The completed flashlight must work. It must withstand being knocked about during use. This seems to mean that the LED assembly, Dorkboard and circuit, and battery tray must be attached to the lantern body itself so they won't break or come loose if the lantern is dropped or jarred, otherwise they might knock about inside the lantern body and be damaged. The Dorkboard is programmable, and the final installation within the flashlight body must allow for easy physical access so that it can be programmed. This means a separate programmer device must be easily connected to the Dorkboard, even with my clumsy hands. I must be able to recharge or change the batteries for the flashlight easily. This implies that determining correct battery polarity during battery replacements should be easy. A recharging cable, if desired, should be easy to connect to the battery tray. The Dorkboard, circuit, and battery should be waterproof if possible. All the components must mount in or on the flashlight in a way that looks interesting. As I set out to achieve these goals, I realize that some of them may require modifications to the existing power circuitry, battery hardware and Dorkboard circuitry.

This photo shows my first Dorkboard mounted on a Radio Shack part number 276-148 PC Board.

As was pointed out to me, the Dorkboard is a great base for projects like this. It has a small form factor, yet is very easy to assemble with only one surface mount component (an inductor) plus a small solder bridge needed. Even so, be careful when you connect wires to the Dorkboard. The topside of the board has no writing on it to cue you, so you have to refer to the Dorkboard diagram to determine which pin is for what purpose. It is easy to connect the wrong wire to the wrong pin. I did exactly that to the Dorkboard shown on the right. I wanted to test it first before adding the remaining circuitry to the PC board. But I misconnected a power wire to one of the Dorkboard pins. The result was a truly awful smell of cooked plastic and the AtMega chip was really hot to the touch. The Dorkboard which is visible on the breadboard in the top photo on this page is my second one. I bought another kit from Brian and assembled it. That one I decided to test on the breadboard first before installing it on the PC Board permanently.

Wait, It Is Alive!

As mentioned above, I actually bought two Dorkboard kits from Brian. I thought I killed the first one as a result of misconnecting the wires. Only after I had assembled and tested the second kit, did I finally get up the nerve to test the first (thought to be dead) Dorkboard. I'm a very nervous person. I went out and bought some Radio Shack 278-016A test jumpers and connected the bottom three pins sticking out of the project board to the breadboarded circuit, powered it up and suddenly the LEDs turned on. In other words, I had not killed it. What a relief! I knew the bottom three pins of the Dorkboard were working correctly: ground, vcc and digital 3. But when I changed the ground and vcc jumpers to the top two pins, nothing happened. Visions of an even more cooked Dorkboard made me hastily disconnect vcc and ground and ponder the situation. I looked at the schematic on Brian's website and wondered if the top two pins might actually be a 5v output and ground. So I emailed Brian about that. He replied that if the LEDs don't come on when I supply vcc and ground to those pins, I'm doing something wrong. I looked again at my soldering of those pins on the PC board solder side and found one that didn't look right. I touched it up and for good measure resoldered the topside connections on the Dorkboard itself, too. I set up the circuit again and reapplied power, and the LEDs happily switched on. The Dorkboard lives!

Move Circuit From Breadboard to PC Board

This photo shows a pen on paper diagram of the physical connections I would need to make on the PC project board when I move the transistor, diode and resistor onto it.

My next step is to move my tested circuit from the breadboard onto the Radio Shack PC Board. That is, I'm adding the transistor, resistor and diode to the PC board and connecting these into a functioning circuit. This step actually had me shivering in fear. I want to freely confess that I'm an amateur technician. What if the circuit didn't work? I would stare at the breadboard circuit for long minutes to work up the courage to transfer it to the PC board. I even tried to get the parts needed to duplicate the circuit locally. The idea was that first I would make and test a duplicate circuit on a breadboard, then I would transfer the first circuit to the PC board and use the breadboarded circuit for reference. The resistors and 1N5819 diode I was able to find, but not the 2N7000 transistor. So I sat down in the early morning with my first coffee, and drew a diagram of the physical connections I would need on paper. Here is a photo of it. This might not be the best diagram, and it actually isn't showing the other 7 LEDs in the circuit. But it is a good enough reference so I could go on and put those parts on the PC board.















This photo shows the PC board after I moved the transistor, diode and resistor onto it.

Here is the topside of the project board, showing the transistor, resistor, and diode next to the Dorkboard.

























This photo shows the more interesting bottom (solder side) of the PC board after I moved the transistor, diode and resistor onto it and soldered all connections together.

Here is the solder side of the project board, showing the transistor, resistor, and diode assembled into the circuit. The black wire connects the Source (S) lead of the 2N7000 to the Dorkboard ground pin. The Gate (G) or middle lead of the 2N7000 is connected to the Digital 3 lead of the Dorkboard. It might be a little hard to see this connection, it is just above the Source lead and a little to the left. The Drain (D) lead of the 2N7000 is shown with the anode of the 1N5819 diode and one lead of the 100 Ohm resistor soldered to it. Those are the two wires you see forming an inverted V. Where is the other lead of the resistor? It is connected to the Dorkboard's vcc pin. You can see the long lead going at an angle to vcc. The two pins right above the black wire are, from left to right, the Dorkboard's vcc and gnd input pins.

















This photo shows in detail how I connected test jumpers on the solder side of the project board to the battery tray and LED array.

You probably wonder how I tested the circuit. This picture shows the details. The black and red test leads you see on the left side of the project board are connected to the Dorkboard's ground and vcc pins, and the battery trays' ground and positive wires. The black test lead you see to the right, about in the middle of the board, is connected to the Dorkboard's ground pin and the ground pin of the LED array. The red test lead you see to the right is connected to the cathode (banded) lead of the 1N5819 diode and to the anode (positive) pin of the LED array.























This photo shows a successful test of the project board circuit. That is to say, the LEDs light up!

The circuit tests out okay! We can see the LEDs are brightly lit. So now we know that the Dorkboard and circuit components are functioning properly on the PC board platform itself. I have successfully moved the circuit off a breadboard and onto a part that can be installed inside a flashlight body in some way. That is one of the next steps. By now you get the sense that I am testing each small change to the circuit, right? I do that because I'm a professional computer programmer who thinks new code ought to be tested incrementally -- so I extend that concept to physical computing and make myself test each small circuit change incrementally as well. This way if something goes wrong I know the problem is in the change I just made.






















Installing Parts Inside Flashlight Body

This photo shows one possible placement of parts inside or outside on the flashlight body.

This photo shows the next challenge: how, exactly, will we install the circuit board and the battery tray inside or onto the flashlight body so we have a useful working flashlight? One placement option is shown here in this mockup. The circuit board is placed only far enough inside the flashlight body to clear the reflector assembly. We don't put it so far in back there that an adult-sized hand can't reach the 5-pin header of the Dorkboard with a programmer or a programming cable of some sort. It looks like placing it a few inches back is a bit tricky. You will need a mighty small hand to manipulate a programmer onto the Dorkboard. And we immediately start wondering how to attach the circuit board to the interior of the flashlight body. This one definitely needs a bit more thinking through! Perhaps we should find a small project box to with predrilled screw holes to mount the circuit board onto. How easily could we run wires for vcc and gnd to and from the battery tray and switch and a wire from digital 3 to the LEDs? We could connect ribbon cable wires to the Dorkboard's programming header and tuck it outside the project box, ready to be easily uncoiled and connected to a programmer when we wish to program the board. Then mount the project box to the inside of the flashlight body. We don't want to permanently install the project box, such as with hot-melt glue, because we will want to access the Dorkboard easily. Another option might be to prop the Dorkboard up vertically inside the flashlight body in some way, securing it against shock.

Now let's consider the battery tray. We could place the tray on the outside of the flashlight body. That way we can easily access it to change the batteries. Mounting the tray on the outside like this means we will have to drill at least two holes in the side of the flashlight, so that we can run the wires to the switch terminals. It might be possible to also hot-glue the backside of the battery tray to the side of the flashlight. This would avoid drilling, but the tray installation would become permanent, which we might not like. We could drill two more holes in the side of the flashlight body to bolt the battery tray to it. The holes could be sealed with dabs of hot-melt glue or silicone to provide waterproofing. But if the flashlight is dropped, the tray might break from the impact. Or the batteries might come loose and spill out, thus switching the light off. The same things might happen if the flashlight is jarred. Mounting an AA battery tray here might not be a good idea. Pretty soon, we start thinking that using AA batteries as a power source might not be a good idea, either. Could we perhaps use 1.4 volt button batteries? Or a pair of 3-volt CR2032 batteries in series, even though we will have to regulate the voltage and that will mean additions to the circuit? The Atmega168 can't take more than 5.5 volts. Four button cells would be 5.6 volts, a little too much. Or maybe a 9 volt battery would be a better option?

This photo shows two very small food containers that might be used for holding the Dorkboard and the battery tray.

The other afternoon I stopped in the Container Store and found these small 4 ounce food containers. It seemed to me that I could drill holes through the containers for running wires through. One container can hold the battery tray and the other the Dorkboard. It probably is not the most professional approach, but is still worth trying out. I bought the containers and spent some time exploring this. The battery tray, I decided, should be mounted on the outside side of the lantern body so one can easily replace the batteries when needed. The container lid would keep the batteries from spilling and rolling away somewhere if the lantern is jarred. I could mount the tray solidly but temporarily by drilling mounting holes in the lantern body and then bolting the try and it's food container using #4-40 bolts and nuts. Two holes drilled into one end of the food container and another two holes in the lantern body let me run the power wires through the container to the interior of the lantern. I mounted the battery tray on the left outer side of the lantern battery. That was an unconsciously made choice, there was certainly no specific reason for it. I could have mounted the tray on the opposite side of the lantern body just as easily.





The Dorkboard installed in the food tray with new wiring hardware for power input and output to the LED circuit in the reflector.

With the battery tray position and mounting details decided, I turned my attention to installing the Dorkboard in its food container. This brought up the issue of how to make wire connections to the Dorkboard. I would need four wires: vcc and ground to power the board, and power and ground going out to the LED assembly from the output circuit. I really needed plug-style connections on the PC board itself. These two-pin connectors with headers, bought long ago from All Electronics, fit the bill very nicely. The top connector has the cathode of the diode soldered to the red pin and the black pin goes to the Dorkboard's ground pin. The bottom connector supplies vcc (red pin) and ground (black pin) to the Dorkboard's vcc and ground pins. The wires come from the battery tray. My guess is that the two sets of stiff wires are holding the Dorkboard pretty much in the same position in the food container, so theoretically it should not knock around much in there. With an all-around plastic shell like the food container, the chances of shock damage seem low. I should probably waterproof the container by putting hot-melt glue dabs wherever holes were drilled. Also notice that I should have no trouble connecting a programming cable to the Dorkboard's programming header. The idea is to just slide the food container out of the lantern body, take the lid off, and plug in the programming cable when I want to program the Dorkboard. If want access to the Dorkboard's circuit, I can just disconnect the wires and lift the board out easily. I'm already thinking of one more modification to the circuit -- adding an LM7805 voltage regulator and appropriate capacitors so I can regulate higher voltages down to 5 volts.





























If you have comments my email address is given below, slightly modified to confuse spammers. You should be able to figure out how to reconstruct the address.

Robert L. Cochran ( cochranb a tt speakeasy.net )

Return to the main page.

This page last updated October 13, 2008