Monday, November 11, 2013

Attention-getting brake light "modulator" for a motorcycle.

Figure 1:
Figuring out how to remove the tail light.  It required
removing the bracket and license-plate holder just to
get to the bolts that hold the light in place.
Click on the image for a larger version.

My brother recently got a Yahama Bolt, a fairly new-model, medium-sized motorcycle.  As is the case with most motorcycle riders, "preventing invisibility" is always a big deal as it is often the case that casual riders of bikes of all sorts (motorized or not!) tangle with a car when the driver of the latter didn't see them!

Among a few other things done to enhance safety and visibility, he wanted to "modulate" the brake light - that is, rather than just going on and off with the application of the brake, that it do "something else" as well.

It is becoming more common that some new-model vehicles blink their brake lights in some sort of attention-getting flash sequence - and doing so makes a lot of sense:  The human brain is very good at detecting when something changes or is out of the ordinary so anything that stands out from the routine is likely to grab a bit of extra attention!  The hope is that if even a single driver is jolted out of a sleepy stupor or their attention drawn from their texting by this sort of thing that it will be worthwhile.

 First, the obligatory warnings and weasel words:
  • The brake light system is a safety device on which your life - and the lives of others - may depend.  Modifying it in any way runs the risk of reducing its reliability, particularly if due care has not been taken during design, building and installation to maximize reliability.
  • There are no warranties or guarantees, expressed or implied, as to the suitability of this project for its intended use, or for any other use.
  • Nothing in this article should be construed as offering an opinion as to the legality of the use of this sort of device.  It is up to YOU to determine if this device is legal/lawful to use.
  • If you choose to construct a device similar to this, it is up to YOU to make it as reliable and safe as possible and YOU assume any risks should any injury to anyone occur as a direct or indirect result of this sort of device!  The author of this article will not be held responsible for any injury or damage or other liability that might result!
  • Improper design, construction and wiring could result in damage to the vehicle's electrical system and/or wiring as well as other safety concerns.  YOU must assure that the work/modification has been done properly to minimize any risks as well as be aware that doing so may void warranties, reduce reliability, cause damage, etc.
  • Finally, the assertion that a "modulated" brake light catching the attention of other motorists and possibly improving overall safety is an opinion rather than a statement based on scientific research or fact and anyone reading this page and/or taking inspiration from it should take it as such!  It is up to YOU to determine if, in fact, this sort of project has positive or negative effects on overall safety!
  • You have been warned!

Figure 2:
 On the bench, the unit  in "dim" (tail light)  mode.
Click on the image for a larger version.
Figuring it out:

First, we analyzed the existing brake/tail light assembly of the Bolt after removing it from the bike.

Using three wires for connection (including a black "ground" wire) it consists of an array of 19 high-brightness red LEDs and internally, it seems to be "diode-ORed" between the two voltage sources.  If voltage is applied to the tail light wire (blue), the 19 LEDs light rather dimly and the entire assembly pulls about 40 milliamps at 14 volts.  If, however, you apply the same voltage to the brake wire (yellow) approximately 400 milliamps is pulled and the result is enough light to give you a bit of a headache and cause you to see red and green spots for several minutes!

Further analysis indicated that the tail light voltage was applied any time that the ignition key was on.  As you might expect, the brake light voltage appeared only when you applied them:  No special PWM (Pulse-width modulation) or anything else was present, this likely due to the fact that this light assembly was (probably) designed to drop in where one might have had an old-style, dual-filament incandescent lamp.

With its using only on/off voltages, this project would be easy!

The build:
Figure 3:
Throwing together the code for the tiny computer.
Click on the image for a larger version.

As strange as it might seem, the easiest way to make a device that flashes the light in a particular pattern is to throw a computer at it!

Fortunately, this is something that is pretty cheap and easy to do these days and I knocked out some very quick "C" code using a compiler for a low-end PIC microprocessor - a PIC12F675.  The device used was an 8-pin DIP (through-hole) processor chip (the same size as a 555 timer) that has a number of useful peripherals like A/D converters, built-in timers and a few other things - but I wouldn't need most of them:  I picked it because it was the smallest, simplest microcontroller that I had laying around.  Some of its features - like the watchdog timer and "brown-out reset" would be used to make sure that it "booted up" reliably and quickly, within a few 100's of microseconds after power was applied, every time.

While the computer code could have been done in assembly, I used C since I have the development tools (suitable tools can also be found for free...) and it was be very easy to bang out quick, dirty, and reliable code just to blink the light!

In the code I defined an array of 0's and 1's in program memory that corresponded to the desired blink pattern (0 = off, 1 = on) and indicating the end of the array is a "255":  The code would simply step through the array from the beginning and stop when it hit "255", leaving the light on.  Between each step a short delay (25 milliseconds) was added to slow down the process and make the blinking perceptible:  Without it, the entire sequence of blinks would have occurred in a few 10's or hundreds of microseconds and may not have even been noticeable!

Figure 4:
 Building the prototype on solderless prototype
board for initial hardware and software debugging.
Click on the image for a larger version.
Just because I was lazy, I defined all of the PIC's pins as outputs (except for the one that can only be used as an input - which I grounded) and the output pin that worked out to be the most conveniently located when I crammed the parts on the board was routed through a series resistor (R3) to an NPN transistor, Q2.  The collector of this transistor was connected to the base of a PNP power transistor (Q1) via another resistor (R2) and when the PIC set the pin to high, the NPN was turned on, yanking down on the PNP's base and turning it on, applying power to the brake light lead.  The total voltage drop across Q1 when the light was on?  Less than 200 millivolts (and a fraction of a watt heat dissipation) - barely even worth mentioning, let alone even noticeable in its effect of the light brightness!

Note:  In the diagram below, I happened to use pin 7 since it was closest to R3, but I could have used any one of the other output pins (shown with no connection in Figure 6) instead.  Do not connect multiple pins together.

To keep the computer happy a 78L05 regulator (U1) was used to drop the 12-15 volts of the motorcycle's power bus to the 5 volts required.  Because vehicular electrical systems are often "noisy" with spikes and glitches, I used a series resistor (R1, 47 ohms) and a filter capacitor (C1, 47 microfarads) to "clean up" the power applied to the regulator.  These components were selected so that not only would spikes be filtered out, but even very brief taps and releases of the brakes would trigger or re-trigger the computer quickly and reliably.  There is also another resistor, R4 which, should the processor NOT boot up for some reason, will pull the base of Q2 high and turn on the light since the hardware default of the processor is to have its pins in a high-Z state:  After all, we do want the light to WORK if your life may be depending on it!

In just a few minutes I had a circuit and its code working on a piece of wireless prototyping board.  After a bit more fiddling of the code to make it flash the desired sequence at the rate that my brother wanted, we were ready to commit ourselves to building a "permanent" version.

Figure 5:
 The newly-built board, ready for testing shown
laying atop the initial version of the
 schematic diagram that was built onto the
prototype board seen in Figure 4.
Click on the image for a larger version.
After analyzing the unused volume inside the tail light enclosure I could see that there was just enough room to cram a small board below the portion of the assembly containing the LEDs (see Figure 8) so I proceeded to build the circuit onto a small piece appropriately-sized phenolic prototype board. As can be seen from the pictures, I didn't make the board any larger or taller than absolutely necessary - at least with through-hole components - nor did I use a socket for the processor since I didn't want there to be the possibility of it falling out.  Were this device to have been built using surface-mount components it could have easily ended up being about the size of a postage stamp!

Once the circuit was built and tested I mixed a big blob of 5-minute 2-part epoxy and liberally coated both sides of the circuit board - this, to completely immobilize the circuitry to protect it from vibration as well as moisture.  Constantly rotating the board for a few minutes to keep the epoxy from dripping off, it soon began to set up and I then used a heat gun to warm it (to about 180F) - just hot enough that I could smell the epoxy, all the while moving the board about since the heat momentarily caused it to re-flow.  After 2-3 minutes of that, the hot epoxy had hardened to the consistency of a rubber pencil eraser so I let it cool.  In another 10 minutes at room temperature it was almost rock-hard, the curing process having been greatly accelerated by the application of heat.

The unit was re-tested and found to be working so we could now wire and mount it within the tail light enclosure.
Figure 6:
 The final version of the schematic diagram of the circuit for "modulating" the brake light.
While pin 7 (CP0) was used to drive Q2, pin 2, 3, 5 or 6 could have been used instead since all of the other pins shown in the diagram as being unconnected flash the sequence as well. While not shown in the above diagram, it is recommended that a resistor with a value of between 10k and 100k be connected between the emitter of
Q1 and the collector of Q2.  Where I to build this again I'd include a 15-18 volt Zener diode across C1 to provide
additional protection against transients.
Click on the image for a larger version.
For wiring onto the existing circuit I bared a short section of the insulation of the light's black wire (ground) and soldered it to the circuit.  Then, cutting the light's original yellow "tail light" wire I put the circuit inline with it, soldering and insulating the connections with heat-shrink tubing.  I then squirted a small blob of silicone seal on the inside of the milky-white plastic housing containing the LEDs where the board would go and plopped it into the small gap where I'd already pre-fit it.  Reassembling tail light housing, it all fit perfectly as seen in Figure 8.

Figure 7:
 The tested and working board, now coated with epoxy and
ready for install.
Click on the image for a larger version.
Testing once again on the workbench to verify that it worked after putting it all back together (it did!) we went back to the garage and after a several minutes of squinting and cramped fingers we managed to get all six of the bolts that hold the light and the shield/license plate holder assembly in place back together using some blue thread locker so that they wouldn't rattle loose.

We now had the light on the bike and working!

What does it flash?

When programming the PIC processor, we changed our minds several times about what, exactly, it would flash.  We first thought of the Morse code "V" which is "di-di-di-dahh" - like the beginning of Beethoven's 5th symphony.

We then tried the word "STOP" in Morse code and adjusted the speed to taste, ending up with a rate of about 44 words-per-minute so that the entire sequence completed in much less than a second.

Ultimately, we ended up with a different Morse message entirely, also sent at around 44 words-per-minute.  This turned out to be a very short, two-word message - the first word being "OH" - the result being a very distinctive, bright, and attention-getting flash sequence.

Can you guess the rest of the message?

Figure 8:
 The completed board, now inside the tail light housing, almost ready to be re-mounted on the bike.  On the underside of the white housing containing the LEDs there is a gap with an angled plastic area, just big enough for the board and the wires entering the enclosure to fit.  Not visible, the board is secured in place to the white plastic using a blob of RTV
(Silicone (tm)) adhesive.
Click on the image for a larger version.

Getting the code:

FWIW, the HEX code for this project - targeted for the PIC12F675 and PIC12F683 - may be found at the link below.

By downloading this .HEX file you indicate your understanding and acceptance of all risks involved in using it, including those that might result in hazard to life and safety and that you have read and understood the warnings near the top of this post.  

There are no warranties expressed or implied and it is up to the end user to determine the suitability and safety for their purpose!

Here are two .HEX files, one targeted for the PIC12F675 and PIC12F683.  The code is identical in function, but allows the builder a choice of processors:
Note:  It was "discovered" that with most programmers, the original .HEX code could not be used due to a hardware conflict with the !MCLR on pin 4.  The .HEX code above and the schematic in Figure 6 have been modified accordingly by tying pin 4 to pin 1.

While I'm not prepared to build custom boards to be installed (it's a matter of time and liability) I can supply a pre-programmed chip at a nominal cost for someone who might be willing to build a board, themselves:  Contact me if you are interested.


This page stolen from


  1. Excellent! This will be valuable to many people. Thanks again for doing this. It works great!

  2. I just may have to order one of those chips..... Could you do a custom message?

    1. Yes, I could do a custom message or sequence since I've not been inundated with requests... yet... Let me know what you propose, but note that it should probably be very short!

      For U.S. addresses, I would guess that $7 would cover the chip and postage/hassle - but that would be subject to change:-)

  3. Nice design!

    Q1 uses the arrow symbol for a PNP. Is this a PNP power transistor and not a TIP31?

    Thank you.

  4. Hi. Answered my own question after RTFMing your write -up. Sorry.

    I do have a question about the code. Since it is in hex and i have not prototyped yet I was wondering if the brake light is always on dim and then bright when the break is depressed? Many bikes if not most today use a single bulb for the running light in the rear and the brake light. When the brake is depressed the light increases in intensity. When not depressed it is always on but dimmer then the brake-on intensity.


    1. The tail lights and brake lights are on totally separate circuits. Internal to the light assembly, I suspect that a pair of diodes is used to allow the same LEDs to be used for both - but each has its own current limiter. Since the current for the brake light is 10 times that of the tail lights, it's very bright compared to the tail lights.

      On the Bolt, the tail light wire has power applied whenever the ignition is on - and this function is completely independent of the brake.

      So, to answer your question: The "brake" light is dimly lit at all times, getting brighter when the brake is applied - but since that's the way it was designed by Yamaha, it's that way here, too.

      One of the concerns that I had was that the Bolt might PWM the circuit to effect a dimming, but since it used separate wires, that wasn't an issue.

      Now, if your bike uses just one wire to the rear-facing tail/brake light and changes the voltage/current and/or uses PWM, things will be a bit more complicated and the circuit depicted won't work as shown. It could be redesigned to work, but such a circuit - and the computer code - would be slightly more complicated.

    2. Hi Clint. Thanks for the response. Tried your code but receive the following error while loading: "Osccal value should be in the form of a RET LW instruction (34xx). Currently 3Fxx. Do you want this changed?" Either answering yes or no results in a "verify" rusults in a ROM error at 0X0000. Any suggestions appreciated.

    3. I have been using MPLAB 8.9x and PICkit 3 (and earlier, the Picstart Plus) for programming and haven't seen an error like that.

      What tools are you using?

  5. Used K150 and received the errors. No errors with pickit 3 but exported file after programing is very different.

  6. It could be that the .HEX output from my PIC C compiler isn't what your programming software expects. I do know that it works with MPLAB, but it may include some addressing space about which the K150 software don't know or can't deal with. It may be possible to produce a file that is more universally accepted amongst different programmers.

    Let me know if the version programmed with the PICkit 3 works as expected.



While I DO appreciate comments, those comments that are just vehicles to other web sites without substantial content in their own right WILL NOT be posted!

If you include a link in your comment that simply points to advertisements or a commercial web page, it WILL be rejected as SPAM!