Introduction: Bike Taillight With a Twist

Picture of Bike Taillight With a Twist

Let's face it. Taillights are boring.

At best they go 'blink blink - look at me! I'm blinking - woohoo' all the time. And they're always red. Very creative. We can do better than that, maybe not much, but still better than just 'blink blink'. I was riding my bike during new year celebrations and people liked it, and not all of them were drunk ;-)

The rest is pretty straight forward: 2x AA cells, boost converter for 5V, some RGB LEDs, the obligatory micro controller, custom printed circuit boards from BatchPCB, perfboard and the usual soldering gear.

Step 1: Main Schematic

Picture of Main Schematic

Really nothing special. If you know how to wire up an AVR chip on a breadboard or an Arduino on a breadboard, if you like that better, you won't have any problems with this one. I used KICAD for designing the schematic and the printed circuit boards. KICAD is open source and as opposed to eagle, which has a free (as in free of charge) version as well, there are absolutely no limitations in the size of boards you can make. You too get gerber files that work with any fab house you want. E.g. BatchPCB had no problems with them.

In the schematic you'll just find the cpu, the LEDs, a few resistors and capacitors. That's all. There's a few headers too. The boards have an ICSP header for flashing a bootloader and a 6pin header for convenient serial upload. The last 2 headers are mirrored and contain power, I2C and two more GPIO/ADC pins.

3 GPIO pins with 3 current limiting resistors are used to supply current to all 8 anodes of a single color. Individual LEDs are turned on or off using 8 GPIO pins to drive the cathodes. Depending on the type of operation the LEDs are either multiplexed (PWM for more colors) or fully on (higher brightness).

Some info on the packages I used for this board:

- ATmega168-20AU: TQFP32 SMD
- LED: PLCC6 5050 SMD
- Resistors: 0805 SMD
- Capacitors: 0805 SMD, 1206 SMD

Step 2: Dealing With the LEDs

Picture of Dealing With the LEDs

I won't go into great detail here, as this has been covered elsewhere numerous times. You just have to make sure you don't exceed the micro controller's maximum output current per pin (about 35mA or so for AVRs). The same is true for the LEDs current. As you can guess from the picture, I used one of the SMD LEDs to figure out the resistor ratio to get well balanced white light. There are three 2k something potentiometers on the other side. That's all. In this case I ended up with resistors ranging from 90 to 110Ω, but that depends on the kind of LED you get. Just use a standard multimeter to determine the LED's forward voltages V_led and you're in business.

Using Ohm's Law, you can calculate the values for current limiting resistors for small LEDs like so:

R = ( V_bat - V_led ) / I_led

I_led should not exceed any current limit of the parts you use. Also this approach is only good for low current applications (maybe up to 100mA) and should not be used for Luxeon or CREE LEDs! The current through LEDs is temperature dependent and a constant current driver should be used.

If you need more info on that topic, wikipedia will have some information. Searching for electrical conductivity of semiconductors (low/high doping etc.) or negative temperature coefficient may be helpful.

I've used 6pin SMD RGB LEDs without commond anything. If you google for them, you'll get many results. The magic words are "SMD, RGB, LED, PLCC6 5050". 5050 are metric dimension for x and y in units of 0.1mm. On ebay you'll find them as well for as low as 50¢ per piece for high volume orders. Packs of 10 currently sell for about 10 bucks. I'd get at least 50 ;-)

Step 3: Backplane & Power Source

Picture of Backplane & Power Source

The backplane provides power and a common I2C bus to both boards. Each board has 8 RGB LEDs and an ATmega168 mcu running with its internal oscillator at 8MHz. The latter requires synchronization between the boards and/or recalibration of the oscillators. This issue will show up in the code section again.

The schematic for the 5V boost converter was taken from the Maxim MAX756's datasheet without any modification. You can use any other chip you find suitable that can provide about 200mA at 5V. Just make sure the external part count is low. Typically you'll need at least 2 electrolytic capacitors, a Schottky diode and an inductor. The reference design in the datasheet has all the numbers.

I used high quality FR4 (fiber glass) boards for this job. The cheaper rosin based boards may work as well, but they break too easily. I don't want the boards to disintegrate on a bumpy ride.

If you already own a 'MintyBoost', you can use that as well if you can make it fit on your bike.

Step 4: You've Got to Have Some Code!

Picture of You've Got to Have Some Code!

In high brightness mode the board supports 6 different colors + white. The color is chosen by setting 3 GPIO pins to high or low. That way all eight LEDs can be fully on, but only show the same color.

In PWM mode the color is set by applying a pulse width modulated signal the the 3 GPIO pins and multiplexing the 8 LEDs. This reduces overall brightness, but now individual color control is possible. This is done in the background by an interrupt routine. Basic functions are available for setting the LEDs a certain color value, either using an RGB triplet or a HUE value.

The device is programmed in C using the Arduino IDE for convenience. I've attached the current code I use. Up to date versions are available on my blog. You can browse the GIT repository using the gitweb interface. Many stupid programming mistakes will show up, I'm sure of it ;-)

The second figure illustrates PWM generation. A hardware counter counts from BOTTOM to TOP. Once the counter is larger than a certain number representing a desired color, the output is toggled. Once the counter has reached its TOP value, everything is reset. The perceived brightness of the LED is somewhat proportional to the on-time of the signal. Strictly speaking that's a lie, but easier to understand.

Step 5: See It in Action

Picture of See It in Action

Just some preliminary tests. Yes it can do full RGB colors too ;-)

Real world testing. Yes we had some snow, but that was before xmas. Now we have some snow again. But, as usual, during the xmas holidays and new year celebrations all we had was rain. Please ignore me groaning at about mid-video, I'm getting old so squatting gets a bit hard.

Finally some slightly improved effects.

Mission accomplished. Geeky taillights, and illegal where I live too ;-) I'm pretty sure I won't be ignored by sleepy or ignorant motorists anymore. By tuning the timings a bit, you can create pretty annoying effects that are good eye catchers. Especially at night.

As there are 4 GPIO/ADC pins on the boards (2 may be used for building a small I2C network), it should be easy to hook up a push button to trigger all sorts of effects. Hooking up a CdSe photo resistor would work as well.

Total material cost is about 50$. The biggest chunk went into the printed circuit boards. Low volume order penalty as usual.

In analogy to a once widely spread TV commercial for a cell phone company in the US, let me ask you this:

"Can you SEE me now? - Good."

Step 6: Updated Design

Picture of Updated Design

I've changed a few things here and there.

Most notably is the addition of a low drop voltage regulator. Now the board can run with anything from 4 to 14V DC. I've also changed the PCB color to yellow and added jumpers to disable auto reset and to bypass the voltage regulator if it's not needed.

Demo code for grabs and assembly instructions. You'll find KiCAD files and a schematic there as well. In case you want one, you can find more info on my blog.

Step 7: Supersized

Next thing on the list: Tic Tac Toe

Step 8: More Light Hack

By adding 3 wires and 3 more resistors the brightness can be doubled. Now two GPIO pins per color are used for sourcing current.

Step 9: More Updates

Picture of More Updates
So I've finally switched from 'dumb' interrupt driven PWM to BCM (Binary Code Modulation). This drastically cuts down the cpu time spent twiddling the LED pins and increases brightness quite a lot. The all improved code can be found on github.

The first few seconds of the video show the improvement in the left board.

Until the next hardware revision of this board is out (waiting for the boards to arrive), this will feed the need for 'more light' a bit. Looking at the new boards running full blast will be painful.


RehabIsForQuitters (author)2014-11-02

This is a great design! I've been looking for a good design for bicycle tail, brake and turn lights. I may borrow your idea if it's cool with you. Thanks for posting this great work!

You have my blessings.

jexter (author)2010-10-25

Great 'structable - thanks!

Regarding the Legal vs. Illegal debate: Car versus Car is a fair fight. Car versus Bike is not. Without drinking a drop, a large percentage of drivers currently drive "impaired" - texting, talking on cell phones, Googling movie start times on their iPhones, trying to fish a Big Mac out of a bag on the passenger seat, etc.

When I questioned a Belgian friend of mine living in New York about the massive dual headlight setup on his bike, he said "Drivers don't think about bikes, and consequently end up hitting bicyclists, because they're not perceived as dangerous. When they see me coming, I want them to believe they're looking at the landing lights of a Boeing 747.  I want them to FEAR me."

When sharing the road with cars, bicyclists NEED to be noticed to stay alive.  If the choice comes down to "living within the law" and "staying alive", I'll always choose the latter.  And if the law is forcing you to make that choice, the law needs to be changed.


madworm (author)jexter2010-10-27

Yes, I know exactly the type of drivers you're talking about. Sometimes I can literally feel their evil stare at my neck because I dare cycle as fast as them and they can't overtake me easily (speed limit) ;-) At the next best opportunity I can hear them rev up the engine and 'restore' the 'proper world order' by letting me inhale the fumes while admiring their taillights.

The more light the better... maybe not blindingly bright, but quite intense nevertheless.

AnalogMan (author)2010-09-07

>> BTW, it's the same thing as staring into rear fog lights. You get blinded as well.

Like driving with rear fog lights on isn't illegal too in every civilized country. :^)

Anyway, since you haven't updated this in ~7mo, you're either dead (bummer!) or distracted, hopefully with interesting things. But if you do get around to that next prototype, just wanted to say, we're still tagged up and lurking.

Who knows? Maybe take a pin off an AVR and interface that mag sensor from your cyclocomputer so that when the bike is moving, it makes all LEDs a boring, ISO-certified vehicle tail light red? Then instead of getting schooled on worldwide laws regarding bike lights the comments would be just about praising your geekness. (shh! keep the secret override switch wiring off the instructable.)

madworm (author)AnalogMan2010-09-07

Civilized... hrmmm... doesn't exist ;-)

And yes, I'm forced to devote most of my time to other unpleasant things.

WKD_Side (author)2010-02-24

dude i've been staring at the third video for so long now i'm so mesmerized lol 

madworm (author)WKD_Side2010-02-24

Don't watch and drive ;-)

kee gee (author)madworm2010-03-26

you crazy and thats stupid hard men..........

madworm (author)kee gee2010-03-26

...don't watch (stare) at the taillights...

BTW, it's the same thing as staring into rear fog lights. You get blinded as well.

JohnMichael (author)2010-02-10

Tail lights are red for a variety of reasons.  one of which is the red indicates that they are tail lights.  Headlights are white.  With white tail lights  you are going to have confused drivers thinking you going opposite directions.  It will also make it difficult for drivers to see other things around you (not behind you.)  In most places white headlights and red tail lights are required by law.   If there is ever an incident between your bicycle and a car  you will probably be found at fault for having misleading lights.
Tail lights are not meant to be exiting, they are meant to be safe.  For that matter, the same could be said for anything related to driving or riding in traffic.
You have a nice set up with the lights, but you need to take legal codes into consideration.
I am also wondering how well that rides in the snow?  Have you found a way to keep it from slipping?

madworm (author)JohnMichael2010-02-10

First, just let me say that this taillight is not necessarily white. It just so happens to be white in this picture. I can't say how often I've been told that "You can't have a white..." already :-)

If you want, just pretend you're looking at the front of the bike. But please don't now tell me that it can't be red. As this thing can display many colors, people can choose any permissible color they like.

Not slipping in the snow is tricky. The best thing I know of is using off-road tires with metal spikes. But that's only worth it if you've got snow all year I guess. It also doesn't help if thick layers of snow are covered with a thin sheet of ice. As I hate changing tires, I stick with semi off-road tires all year and switch to biped mode if it gets too dangerous.

ricky97red (author)2010-01-07

hey whats up im really intrested in science and building stuff but i don't have access to all of the right materials cause im just a child and i spent all my money on christmas stuff but i really like your creation and would like on ... do you know of any where i can get it with alll the settings and stuff ordered to me on the cheap?

madworm (author)ricky97red2010-01-07

Hmmm. Fully assembled, small quantity and cheap. That's a tricky one. Unless you have these things made in quantities (100s and up), there's no way I know of to make it any cheaper. You could have the prototype if you want it badly, but you're not going to like the price tag on that one. It might not even fit your bike.

I'm thinking of having a small series of the circuit boards made, but that will take some more time. The next prototype is still a several weeks away.

Alpvax (author)2010-01-07

nice. just got a new bike for xmas as well :P

dchall8 (author)2010-01-04

The color issues seems to be well covered in the comments so I'll pass on that specifically. 

THIS IS GREAT!  Good job!!  I like the rotating ZOWIE look as an attention grabber.  I was sort of yawning until that came on.  Could make those counter rotating and then reversing?  Are there other patterns available? 

If you did away with the multi colors, would that simplify the electronics? 

madworm (author)dchall82010-01-05

Here's just one more.

nybras66 (author)madworm2010-01-05

YEAH! This is a good regular back-light! :D I want one for my jackets and two for the shoes!!! Stunning! :D

madworm (author)nybras662010-01-07

I'm working on a new prototype right now. It will have a voltage regulator built in, so it can run with anything in the range of about 3V to 14V. That should make it a bit easier to use it.

madworm (author)dchall82010-01-04

Oh, and I forgot: both LED rings could be driven by just a single micro in single color mode. That makes about -3$ in part cost. But you'd need 8 more wires on the perfboard... I'm not sure if I'd be willing to spend more time with soldering just to save 3 bucks. I like my boards neat and clean and having to many wires mushroom on there gives me a headache. YMMV.

In terms of programming using just a single micro would make things easier. No worries about drifting clock frequencies and the patterns going out of sync. The drifting is due to the fact that I didn't use a crystal (yes, I was lazy and didn't want to route a complex board), but the internal RC oscillators. They are only good to within 10% or so without recalibrating them. And that needs more gear, frequency counter or even better a scope.

madworm (author)dchall82010-01-04

Going for just a single color could still give some more brightness, if needed. You could just wire the LEDs to +5V and the cathodes to a resistor and that to a free pin on the chip. The part count would go up by 5, but you'd save quite a bit money by not using RGB LEDs. Currently the chip also feeds the anodes due to color selection, and that limits the current to about 35mA combined. In single color mode you could supply up to 20mA per LED and still stay below the chip's max. total current.

The complexity of the electronics stays the same, but it's pretty low anyway. On the programming side it would get easier. Just turn 8 LEDs on or off. Can't be much simpler than that. Creating patterns is just using a bunch of for loops and a bit of thinking. The human eye is slow enough, so you can get away with a lot of tricks to make things look right ;-)

You could even use a smaller micro, but when looking at the price difference between say the ATmega168 and e.g. an ATtiny2313, you may save _one_ € in part cost. If I wanted to sell thousands of these I'd consider it, but that's not the case. Also I'd lose the convenience of using the Arduino IDE for programming it. I could use AVRStudio or a makefile, but the Arduino way is so d**n easy. Never change a running system!

nybras66 (author)2010-01-03

Here in Italy (but I thik all over Europe, whit few excetions, like France and Britain - and only God Know why...) is the same of Canada. The standard communication signals must be observed. Red is "no, stop, don't go, stay away, danger" in every corner of the world. "Hey! I'm here! Pay attention, Don't pass over this poor biker!" is a good message to be send to cars. Red color is the appropriate choice for this.
White on the front is (obviousy) to give you a better view light. Yellow color is for lateral side and direction segnalations. This color code must be respected, imho, so you can know what is the direction/condition of a far veicle, even in bad view situation. Maybe It's boring, but it's safer.
After this, every idea to catch more attention from drivers maybe a good upgrade. Blinking is a first simple step: here we have the so-called "third eye", a blink red (led) super light in the top central rear glass of the car, that pulse directly in driver's eyes on brake use.
Your light show is a wonderful work, but what if anyone do the same? The road is not a dancehall. Oh... well, ok... new year celebrations excluded. :)

madworm (author)nybras662010-01-03

Hmm, so maybe I should stick them to my ears instead ;-)

That would be a good "lateral indicator".

nybras66 (author)madworm2010-01-05

Hmmm... this could be regular, if yellow! :D

stephenniall (author)nybras662010-01-03

Same in the uk .

I got pulled over by the police the other week for having blue leds on my bike their reserved for goverment vehicles apparently!

Rob K (author)2010-01-04

With this how could others not notice you.

Count Drunkula (author)2010-01-04

Leaving aside local laws, red light does less damage to the eye's ability to see in low light situations due to afterimages.  Red lights on the rear allow for visibility to other drivers without making it harder to see when they look away.  White/blue light is very powerful and is used in headlights and reverse lights so that the vehicle operator can see well.  You'll be extra visible but the driver in the car behind you will have a harder time seeing anything else until about a minute after you two part ways.

madworm (author)Count Drunkula2010-01-04

That's a good point you have there.

Then all the traffic on the other side of the road had better have red head lights ;-)

So far I've only been temporarily blinded by excessively bright taillights of cars and xenon head lights. The former were so bright that my eyes hurt. All of these are perfectly legal. Compared to them this little LED toy is harmless.

and-reas (author)2010-01-04

Same here, only red at the back.
However, I do know I got a lot of attention with my christmas lights:
They were shining downwards so no blinding other people. They got really distracted by it instead =p

sml156 (author)2010-01-02

I looked up the law for bycyle lights in canada and here is what I found

62(17) - Lights
a bike must have a white front light and a red rear light or reflector if you ride between 1/2 hour before sunset and 1/2 hour after sunrise and white reflective tape on the front forks and red reflective tape on rear forks.

madworm (author)sml1562010-01-02

Hm. The "front = white / back = red" ideology seems familiar. Never heard of additional reflective tape though. Different countries have somewhat different regulations I suppose. In general I think that more light and or reflective surface is better, no matter what the color is (in case of bikes, not motor cycles or cars).

Personally I think having reflective tires should be mandatory. As most of the lights/reflectors are  mounted pointing along the bike and _not_ sideways, they're pretty useless in a 90° situation. Also reflective inlays in tires don't have the habit of falling off, like all the other spoke attached contraptions do.

its2l8men (author)madworm2010-01-03
in my country there's no law for bicycles a bike with no lights are ok the police won't care
sml156 (author)madworm2010-01-02

the way I read it I think the law states you have to have either or both. On my bike I have whats called tire fyls they are led's that screw onto my tire valve stem and blinks when there is movement of the tire. they also fit on motorcycles and cars

wupme (author)2010-01-02

A friend of mine had his whole bike (custom build for him) painted in special a light reflection paint.
The wheels are also reflective, there's just no way for any vehicle with lights to oversee him.

But besides that, it just looks awesome by night :)
I never asked him how much that bike was tho... i dont think i want to know that anyway.

Kiteman (author)2010-01-02

That's probably illegal in the UK, but very cool.

Nice job.

wupme (author)Kiteman2010-01-02

 In germany they are illegal too.

You'r supposed to have a white frontlight and a red backlight. And if the backlight aint always turned on (if you got a dynamo and no "standing light") you need a backreflector too.
Oh and your suposed to have 2 reflectors in each wheel or an equal alternative (like reflecting wheels).
Battery powered light are ok, as long as they battery has enough power ;)

Only situation this would be legal is if you drive backwards but uhm.. yeah i guess its illegal to drive backwards all the time, not to mention pretty hard to do too lol

lemonie (author)2010-01-02

On public roads these are probably illegal most places. However, you'll have the red-only option? Nice device.


madworm (author)lemonie2010-01-02

Yes, you can have any color you like. Just change the code and/or add a switch.

madworm (author)2010-01-02

Of course it is illegal, but what isn't these days ?

Strictly speaking even my head lights are illegal. Battery powered lights are only permitted here, if you ride a racing bike weighing not more than 11kg. But on the other hand, from my experience police officers are quite happy, as long as you have working lights on your bike. Or they just don't care. Who knows.

lemonie (author)madworm2010-01-02

The cops might "have a word with you", but if you can flip them to red I'd think you'd be OK.


Project_Nightmare (author)2010-01-02

 Great project. Could you please post the Eagle files for the LED Boards?

Eagle, hmm. I didn't use Eagle but KICAD. What to do now ?

Here's a link to the gerber layout files if it helps. If you just want to make copies that should work.

About This Instructable




Bio: Slightly Dorky High Nerd - You might find some of my stuff on Tindie.
More by madworm:IKEA Samtid mood-light upgradeIKEA Samtid reading light upgradeBreadboard LED indicator
Add instructable to: