Helmet Plus Bike Light
Last week I was getting tired of forgetting my bike lights at home. Here in Boulder, CO there are laws stating that if you are riding a bike at night and get hit by a motor vehicle, no matter what the cause, if you do not have a front and back light you are responsible. Besides not wanting to pay for a motorist's car, I don't wanna get HIT! So with all this in mind I started learning about LEDs with the goal of putting some on my bike helmet.
Not everyone here at SFE is a electronics wizz. Yea, I know a little about Arduino and I pride myself on being 'decent' with a soldering iron but that's about it. For this little project I had to learn about how LED's work, what a current limiting resistor was and how to pick one out. I'll out line this whole process below...read on!
For this project I wanted to add two sets of LEDs to my helmet, three white ones
in the front and three red ones
in the back. I used these because the are super bright, relatively small and don't use much current (you'll see this explained later).
I grabbed these six LEDs from the shelf and snagged a battery to start playing with this stuff. What next? I don't know. To the internet Batman...
Searching for 'LED circuit basics,' this
was one of the first pages I found, the diagrams are especially helpful. As the previously linked webpage states, when making an LED circuit you first have to decide what 'type' of circuit you are going to make, a series or parallel circuit. The choice (for LED circuits) depends on how much voltage your power source can supply. From the product descriptions I saw that the white LEDs should be used at 3.4 volts and the red ones at 2.4 volts.
As the LED tutorial examples show, if I connect all the LEDs in series (one after another) with this battery I get-
3V (and example battery power) / 6 LEDs = 0.5 V/LED = 0.5 V per LED
Will half a volt for each led light it up? No, not even close. As the description said there needs to be at least 2.4 volts to even get the red LEDs to turn on. In order to light all of these with one battery in series, I'd need a 17.4 volt battery (3 * 2.4V + 3 * 3.4V = 17.4 V). Instead of hooking up two car batteries I should look into a parallel circuit.
Further down the LED Circuitry Tutorial the parallel circuit is outlined. Reading you'll discover that LEDs set up in this manner all receive the same voltage, perfect!! Looking at the LEDs I need a battery that can supply about 3.4 volts (highest of the two voltage ratings). All of our LiPo batteries supply 3.7 volts so it was a natural choice. Plus they are pretty small, good for bike helmet mounting.
Now before we go plugging LEDs into batteries, we have to take into account how the electricity will act once the LEDs are powered up.
With electronics when you attach something to a power source, for instance if you take a wire and touch both ends to the positive and negative side of a battery (NOTE: Don't do this!! It is only an example) you'll see some sparks and probably some smoke. This is because with nothing connected to use the power the battery provides, the wire is telling the battery to 'give me all the juice you have!' It's kinda like having one of those above ground pools and cutting a hole in the side, all the water is going to rush out as fast as it can, probably splitting the side of the pool. And same as with the wire, if you plug an LED directly into a battery, all the juice will flow into the lighting element and burn the LED out. This effect in electronics is called a 'short.'
So with electronics you need to have something limiting how much power the battery can let out, similar to adding a valve to our swimming pool (instead of a hole) so you can adjust how much water flows out so the sides don't burst open. The electronics equivalent of the valve is called a limiting resistor (limiting = what it does, resistor = what the component is called). Resistors come in different values, which indicates the resistive value - ie, how much juice will be allowed through. To figure out the value you need we have to get into some math, ready? OK, go.
There is a simple equation that governs how electronics components react when power is applied to them, it is called Ohm's Law. This interaction depends on three things, the voltage (how much water is in the pool), the current (how much water wants to flow out of the pool at once) and the resistance (the size of our valve restricting the valve flow). Here is the equation in all its glory-
V = I R
Here is each variable broken down-
V = Voltage (measured in Volts (V), just like you see on batteries)
I = Current (measured in amps (A), or milliamps (mA), 1 Amp = 1000 mA)
R = Resistance (measured in Ohms (?), 1 Ohm = 1 volt / 1 Amp)
Now we can apply this to our problem. In the helmet example I have six resistors all rated at 20 mA. So we know our voltages (of the battery and the LEDs) and current requirments so we just need to find out what R is in the equation above. With a little algebra we get-
R = V / I
Now you might ask what value for 'V' do I use. In Ohms law you need to use the voltage drop
in the circuit. This means the voltage the battery supplies minus the voltage the LEDs require. That's easy enough but hang on, the LED's have two different voltages (red = 2.4 V and white = 3.4 V)! Well shoot, I'll just average what the LEDs ask for and call it good-
(3.4 +2.4) / 2 = 2.9 Volts
The only other bit need is the current. This is easy, just add up the current values (I) for each LED. Handy for me they were all 20mA-
6 * 20 mA = 120 mA
In order have the units match up right the current needs to be in amps, not milliamps. This is an easy fix, just divide the millimamp value by 1000.
120 mA / 1000 = 0.12 A
Now we are ready to plug all this into the rearranged Ohms Law-
R = (3.7 V - 2.9 V) / .12 A
R = 0.8 V / 0.12 A
R = 6.667 ?
Since the resistors are not made for every single possible value a resistance can be, its ok to use something close by. Generally, a resistor rated up to 10% over your calculated number is acceptable. Perfect, I'll just hook up a 3.7 volt LiPo battery with a 6.8 ? resistor and I should be just fine...right? Well here is what happened-
First try lighting the LEDs...what the?!
off you notice only three of the six lights are on and only the red
ones. That’s strange. Remember when doing those calculations I assumed the average voltage drop for all the LEDs? By doing that I dismissed the fact that the two types of LEDs have different resistances. In electronics, the power (current) will take the path of least resistance. Just like it’s easier for the water to rush out of the hole in our pool then to hold itself together inside the pool. From the picture it seems the red LEDs have a lower resistance then the white ones. To know for sure we look at Ohm’s Law again-
For the three white LEDs-
R = V / I
R = 3.4 V / (3 * 20 mA)
three LEDs at 20 mA each
R = 3.4 V / 60 mA
R = 3.4 V / .06 A
remember we have to use amps for the equation to work
R = 56.667 ?
For the three red LEDs-
R = V / I
R = 2.4 V / (3 * 20 mA)
three LEDs at 20 mA each
R = 2.4 V / 60 mA
R = 2.4 V / .06 A
again, we need the current in amps for the equation to work
R = 40 ?
As we expected, the resistance was lower for the red LEDs then the white ones. So how is it possible to light both sets up? We’ll need two resistors, one for the red set and one for the white set so that the battery detects the same power request from both sets of LEDs. Since the power will be flowing from my battery, to the white LEDs first then to the red ones, the resistors can be in line and I don’t need two separate circuits (see the pictures below). Here is what happened on the second try-
Now we’re talkin!
That’s exactly what I was going for. It’s a little hard to see exactly how this is set up, here is a diagram that is showing how its all wired together (I’ll use a bigger battery for the actual usage, this picture was just easier to use)-
The parts and wiring
This is what an electronics diagram would look like if you drew out this circuit with the proper symbols for each part -
Ahhh!! What is that?!
You can see the LEDs have an icon that looks like a little arrow (the D1s and D2s). This is because the power can only travel one direction through the LED, all electronic ‘diodes’ act in this manner. LEDs come from the factory with one long leg and one short one (see this on the ‘parts and wiring’ picture?). The positive side of the battery (usually the red wire if it has a wire lead) needs to be hooked up to the long leg of the LED. You can see this on the battery in the diagram (BAT1), it has the + and - near it. If your LEDs aren’t lighting up, check this first! The little squigely lines are the resistors (R1 and R2) and the straight black lines will be wires/connections. It’s also nice to have red and black wires when you are connecting the parts…helps keep things straight.
…and they put him back together again…
Now that we have all that settled here comes the fun part, adding the LEDs to the helmet! I wanted this to be as low profile and as light as possible. Here is all the hardware I chose-
All the parts
As well here are links to all the parts on the SFE website (in case you want a closer look of course)-
You’ll also need some hook-up wire
to connect the boards together.
I decided that it would be good to have a switch as well so that I could turn the lights off, say if I was riding in the daytime. Doing this changed my circuit drawing a little-
The circuit diagram
You can see the new component in the green outlined box. Having this blue print really helps keep things straight when you actually start putting things together. The different colored outline/boxes/curves in the above drawing will be different PCBs with the enclosed components on each.
Next I laid out where on the helmet where the different parts would sit and sketched out where the wires would go. I even went as far as holding the little PCBs on the helmet and tracing out their sizes-
You can kinda see the white marks
Next I took an old soldering iron tip and melted little notches in the styrofoam for the wires and boards-
The power of an old soldering iron!
This made measuring the wire to fit much easier. Which I did and had set to the side. As I made one board, I soldered the wire segments to it before I started on the next PCB.
Next up was soldering the battery connector, first resistor and switch to the first PCB (the green set in the wiring diagram). I kinda shot myself in the foot here picking such small components. Soldering all these little bits together on such a small board was a challenge, I actually had to re-do it once ‘cause I melted the JST (battery) connector-
The front of the switch board…
…and the back of the board
To solder these parts together I referenced the wiring diagram quite often. I made sure to connect where the red (positive) lead of the battery plugged in, out the same leg of that connection on the connector to a resistor, then to a red wire coming off the board. Then I connected from the pin on the connector that connected the black (negative) battery wire to a black wire coming off the board.
Next on the blue print is the red box. For this set I took the green PCB and cut it in half since there were only going to be three LEDs on it-
…and the back.
You can see this looks very similar to the wiring diagram, a good example of hooking the LEDs up in parallel with solder.
Now on to the last PCB, the purple outlined box on the schematic. This one was a little tricky since there needed to be a resistor as well-
Next I mounted the battery. I decided to use Dual Lock
, a 3M product. This holds like no bodies business and doesn’t get twigs and pine needles stuck in it like regular Velcro does.
The battery in place
The Dual Lock
Once I got all the boards mounted, wired together and checked to make sure they were working (ie flipped the switch), I hot glued all the wires in place to keep any hungry sticks at bay during my bomber night time down hill rides-
The wires hot glued near the switch circuit
And that wraps up this edition of making LEDs turn on, if you follow these simple instructions step by step they won’t let you down