Introduction: Flashing LED Top Tube Pad for Your Bike
Well it's that time of year again. That's right, the sun is going down early, and it's getting hard to avoid logging some miles on your bike after dark. You likely have great lights front and rear already, but what about on the sides of your bike? When crossing intersections, and cruising down those long stretches of unlit roads, a biker can be easy to miss.
Say hello to the led clad top tube pad. Not only does it provide a little protection for your bikes paint job. It also provides a lot of protection for you when riding in the dark. When I sought out to build this project, I had some simple goals in mind.
1. It needs to be self contained
2. It needs to bring lots of attention to the bike with out distracting the cyclist.
3. It needs to look clean
With this in mind it was time to put together a shopping list.
Step 1: Time to Pick Up Some New Toys.
Here is what we need to put this together.
We can get all of our parts from Sparkfun. I have also included the code for this project later in the instructable.
Arduino Pro mini x1
If your new to the Pro series Arduino, you will also need an FTDI basic. This let's us program the Pro mini over usb.
Resistors x 11
Wire Wrap Wire x an assortment of colors. Probably no less than 4 colors.
Don't forget a charger. Lipos need a special charger to keep them from exploding.
Step 2: I Hope You Have Your Thinking Caps On.
Let's take a moment to explain exactly what is going on under the hood. This step is going to be a bit of a data dump, but this will be very useful information when your putting this together, and working with the code. This is important to understand before going further. We'll get to the fun part soon enough.
I have used tri color leds so that we can use a whole variety of colors to match your mood, and your bike. The system is a bit complicated because of these leds though. Tri color leds have 4 pins. 1 is ground, and the other 3 are color pins (Red, Green, Blue). In a normal set up you would usually connect the ground to the Arduino ground, and pull each color pin high to change colors. In this system that would mean with 11 leds, 3 colors each, we would need 33 I/O pins!
Unless we strap a Arduino Mega to this thing, there's no way that we can make that work. So here are a few tricks that I pulled to get the pins down to a more respectable number.
Let's look at the layout. Instead of wiring it like this
We will wire it like this.
By strategically wiring two leds to act as one, we cut down that initial 33 to 21. But that still won't cut it, we need to bring that down even more. So the next trick, instead of giving each led it's own I/O pins for color, we will make all 11 leds share the same I/O pin for each color.
Why you ask? This way we only need 3 pins. This brings down that 21 to 3. Much better, But wait... If they all share an I/O pin won't they all just turn on and off at the same time?
Remember that tricolor leds have four pins? 33 pins only considered the color pins. We still haven't done anything with the ground pins.
We will give each ground pin an I/O line of it's own. This will let us control which leds are on and off by toggling the Ground pin low, when a color pin is high. We change the color by toggling different color pins high. If Blue is HIGH, green and red, are low, and 1, and 3's ground are low, and 2,4,5,6,7's grounds are high, only 1, and 3 will be on and will be blue.
If you want all of the leds off, you can simply pull the 3 color I/O's LOW.
Make sense? I hope so. Make sure to look at the schematic below, it should help some.
Step 3: Let's Get to Building This Thing!
Did you manage to make it through that last step? It takes a little brain digestion, but it's nothing you can't handle. Right? So let's have some fun now.
I found a vinyl top tube pad works best for this project. The leds are the same size as most solder tips. This is great because we can grab an old solder tip, and simply melt the vinyl and foam for our our led holes. Just poke your tip through in the pattern that you want your leds. And you'll be set to place your lights right in to the pad. It gives a nice clean look when it's done, and is just about a perfect fit. Be sure you use a lower temperature on your soldering iron as the foam will melt quickly, and you don't want your holes loosing their snug fit.
Step 4: Time to Get Soldering.
There's no turning back now. We have burnt holes in our pad. Now it's time to break out the iron, and get down to work. There are 44 pins to solder wires to. I found the best way to get this task done is to work on one pin at a time. Start with the Red, and do all of each color as you go. There will be a mess of wires by the end of this. You will want to keep the wires organized.
In my photo below of the Arduino all wired up, you may notice Green, Red, Yellow and Black wires. Pretty simple stuff, Green to Green, Red to red, Yellow to Blue, and Black to the individual I/O line to control the specific led.
Remember that layout we were looking at earlier?
When soldering your wires you will want to link 4 leds in pairs. This will allow 1 control pin for both leds.
When your done soldering wires you should end up with 7 ground wires, and 3 bundles of 7 color wires.
Step 5: Attaching the Leds to the Arduino
I soldered the resistors directly into Arduino pins 2-8. These will be your control pins. The color wires are attached to Arduino10-12. Solder it all up, and your ready for code.
Copy and past the code below into a Sketch in Arduino. There are a few notes in the code to help you modify the colors, and patterns if you would like to.
/* Source code for top tube bike light.
Written by Timothy Holmberg
int l1 =2; //gnd control pins
int l2 =3; // that is a lower case L not a #1
int l3 =4;
int l4 =5;
int l6 =7;
int l8=10; //color
// By pulling this high, we are keeping the color green.
// If you want to change colors in your pattern, you will want to pull
// these pins (l8,l9,l00) high and low in the void loop, not the void setup.
digitalWrite(l1, LOW); // all I am doing here is calling individual leds to turn on and off.
//Try changing things up. See what happens.
Step 6: Go for a Ride.
It's all up and running. Now just wait for the sun to go down, and head out for a ride!
First Prize in the
Light Up the Night! Contest