loading
Picture of Bar End Brake Light: BEBL
DSCN8150tinysquare.JPG
DSCN8150square.JPG
DSCN8250.JPG
DSCN8251.JPG


Overview

Group riding would be much safer if bikes had brake lights.  The lack of brake lighting on bicycles has lead to the audio cues of "SLOWING" or "STOPPING" being shouted at every turn.  While this may enhance safety, it certainly cuts into the serenity of a ride.

This project offers a viable solution that can increase both safety and serenity on a group ride.  With embedded programming made easy by the Arduino integrated development environment, electronics getting smaller, more capable, and cheaper, this project is possible for the do-it-yourselfer.

BEBL Challenge!  Be the first, and get your hardware cost reimbursed.  I will award a $35 reimbursement, by mail or PayPal, to the first person to post a video online that demonstrates a functioning and mounted Bar End Brake Light made from these plans.  Looking forward to seeing your project.

Design Criteria
Other than the obvious criterion -- light up when braking, I wanted this light to look cool, cool enough to mount on any expensive racing bike.  This rules out any visible wiring.  I also wanted the light to be portable, meaning it will work on more than one bike.  Thus no brake-lever specific triggering should be used.

Solution
The final design is centered around a 3-axis accelerometer board provided by Pololu.com.  This product is simple to use with an Arduino, small enough to fit inside the handle bars, and best of all cheap at $15.  Also, this accel has an on-board voltage regulator that we will take advantage of to power the whole circuit.

The processing takes place in an ATmega328 programmed with Arduino.  These chips can be also be programmed directly in C, but Arduino takes care of a lot of setup and generally makes programming less tedious.  Arduino has everything this project needs.  The ATmega168 would probably suffice for this project but the ATmeta328 at $1 more, provides 2X the program space.

Mounting the computer inside the handlebars provides an enclosure for the project. 
 
Remove these adsRemove these ads by Signing Up

Step 1: Schematic, layout, and bill of materials

Picture of Schematic, layout, and bill of materials
bebl_schematic.png
The schematic and layout are included here for those who don't want to wade through detailed instructions.  This schematic is for a potential printed board in the future.  There was no room for the serial interface on this wired board so these elements can be ignored.  I've indicated the unnecessary parts on the schematic and have omitted them from the layout.  The slave LED D2 is not shown in the schematic but is placed in parallel to D1 as otherwise indicated.

Let me know if you are interested in a printed board.  We can combine orders and save!

Parts
Accel -- 3-axis accel breakout $15
6V battery -- Lithium 28L $5 each

SparkFun
S2 -- Surface mount right angle switch $1
IC1 -- AVR ATMega328 w/ arduino bootloader $5.50 (Consider getting this from ladyada.com, for her supped up bootloader)
LED1 -- Super bright LED red $1 each x 2
Osc1 -- 16 MHz oscillator  $1
28-pin DIP socket $1.50

Radio Shack
C1, C2 -- .1 uF ceramic cap
R1, R2 -- 220 Ohm resistor
Project board $2

Bar tape and plugs.

Total cost around $35, battery included.  I'm not including the cost of the bar tape, since you need to have that anyway.

Step 2: Prepare board

Picture of Prepare board
DSCN8218.JPG
Cut the printed circuit board (PCB) into three strips with a Dremel tool as shown.  Viewed from the top side (the side with white markings), the middle section of the board should have 2 holes on the left side of the central rails and 3 holes on the right.  The widest board that my handle bar will accept is ¾ inches.  So, although I would prefer 3 holes on each side of the central rails, there is not enough width to accommodate that.  Measure the inside diameter of your handle bars and cut the middle piece to fit inside, being careful not to mar the copper on the bottom surface.  One of the edge pieces will be the slave board.

The outside pins on the oscillator (Osc1) will be aligned with pins 9 and 11 on the socket but need to connect to pins 9 and 10 on the socket however.  To prevent the unwanted connection, cut a slice out of the copper to isolate pin10 from the other holes (shown in white on the diagram).  With a multimeter, verify that the connection is severed.

Step 3: Solder master board

Picture of Solder master board
PCB_cut.png
DSCN8230.JPG
master_diagram.png
On the bottom of the board, note that socket PIN1 is on the right, VCC rail is adjacent to socket pins 1-14, and the GND rail is adjacent to pins 15-28.  The rails are labeled in the photos below.

Solder the pieces in place:
 
–28-pin DIP socket. 
Remove socket PIN11 from the socket.  We will not be using this pin and it gets in the way.
PIN1 of the socket should be in the 2nd row of the PCB on the left (2-hole) side.  This saves the first row for the LED, (yes, I learned this the hard way).  Solder only the corner pins of the socket at this time.  The remainder will be soldered later.

–The oscillator is a large piece that just barely fits in my bar.  For a better fit, the leads on Osc1 are notched so that they rest on the board.  Trim those notches off, so that the base of the oscillator slides all the way down to the board.  Place Osc1 next to pins 9, 10, and 11 on the socket (Either direction is fine).  Solder PIN1 of Osc1 to connect it to PIN9 of the socket.  Solder a jumper, sharing the hole with the middle PIN2 of Osc1 to the ground rail.  Finally, arch the uncut lead of  PIN3 of Osc1 and PIN10 of the socket together and solder them both in place.

–Solder the remaining pins of the socket.
 
–C1 to socket pins 7 and 8 (Either direction is fine).
Before trimming the leads, bend the lead of C1 connected to pin 7 across to the VCC rail and trim to length.  Solder in place.  Add a piece of insulation to the other pin of C1 connected to socket PIN8 long enough to reach the ground rail.  Trim to length and solder in place.

–C2 to socket pins 20 and 22 (Either direction is fine) in the outer most holes of the PCB.  This will allow room for the accel jumpers later.  Before trimming the leads of C2,  bend the lead connected to socket PIN22 over to ground, trim to length and solder in place.  Bend the other lead of C2 connected to socket PIN20 over to PIN21, trim to length and solder in place.
 
–Solder jumper from socket PIN20 over GND rail to VCC rail.

-- Solder Accelerometer
The voltage regulator on the accel saves us from having to add a separate power supply circuit.  The Accel VIN pin is powered directly from the battery.  Then the regulated 3.3V on the Accel powers the VCC rail on the board.

Test all junctions for connectivity and shorts.  If the board checks out this far, you're ready for the accelerometer.  If not, start over with a new board and parts.  Mistakes get expensive at this point.  Short GS2 on accelerometer by adding a jumper between the two holes labeled GS2.  This provides medium sensitivity of plus or minus 4 Gs.  Unfortunately, there is not enough room in the handlebar to use the provided jumper.
  
Solder Accel pins next to the socket.  On the top side of the board, connect Accel analog output to the A2D pins.  Leave no excess wire here.  These wires should nestle tightly between the socket and C2.
–Jumper Accel z to pin 28
–Jumper Accel y to pin 27
–Jumper Accel x to pin 26

On the bottom side of the board, solder Accel 3.3 to the VCC rail. Solder a
jumper Accel GND to the GND rail,

Solder one end of a flexible 6-inch lead Accel VIN.  This will eventually connect to the bar end switch S2.  We will trim to length and attach the other end later.

Solder one end of a flexible 2-inch wire to the ground rail.  This will connect the negative battery terminal to ground.

Step 4: Solder slave board

Picture of Solder slave board
Solder:
-- the four pins of the right angle header onto slave board.
-- a jumper wire to pin2 of the right angle header.  Leave the other end of the jumper free for now.
-- resistor R2 to pin3 of the right angle header.  Make sure the other end of the resistor can reach the LED lead.  Leave that end of the resistor free for now.

Step 5: Prepare master bar end

Picture of Prepare master bar end
DSCN8238.JPG
Test fit the master board into the handlebar.  The board, resting on the bottom of the bar, should be below the middle.

Orient the bar end to the desired angle.  In my case I wanted the "B" to be upright.  With a hobby knife cut away the top portion where the board will sit, up to the second rib of the bar end as shown in the diagram below.  This will provide a platform for the PCB.

Drill a 13/64-inch hole for the LED D1 through the center of the bar end.  This size allows the back ring of the LED to seat nicely against the inside of the bar end.

Delicately remove the rubber behind the face of the bar end with a hobby knife for the switch to fit snugly.  The back surface of the face will provide a surface to glue the switch to and leave a nice finished look.

Bend the leads of the surface mount switch flat.  (You may not need to do this, depending on your switch.)

Install the switch.  Hot glue or epoxy the switch in place with leads pointing toward the PCB, leaving the switch accessible from the bottom.  Use the glue sparingly to avoid gumming up the switch mechanism.

Drill two tiny holes through ribs to provide wire access to the leads of the switch.  Well-placed holes will make soldering easier.  Align the holes with the middle lead and an outside lead.  The holes should be next to the shaft of the bar end so they don’t inhibit installation on the bike later.  If you don’t have a tiny drill bit, a wedge cut with a hobby knife will serve the same function.

Trim jumper from socket pin4 so that it just reaches the switch through the recently drilled hole.  Delicately solder in place.

In the other hole, insert a 6-inch jumper and solder to the switch.

Step 6: Install LED D1

Picture of Install LED D1
DSCN8241.JPG
Using the same PCB hole, solder 220-Ohm resistor and 50-inch wire to socket pin4.  The 50-inch wire will pass up through the board and the resistor lead will pass down through the board.

Connect one end of a different colored 50-inch wire to the ground rail.  We will trim to length and attach it later.

Insert the LED into the bar end, making sure the LED is pushed against the back side of the plug.  The LED should poke out of the bar end.  Test fit the bar end to the board and note how much the anode (long LED lead) overlaps with the lead from R1.

Remove the bar end and solder anode to R2 so that the LED reached the end of the bar end.  Redo if necessary to get a good fit.

Solder the cathode (short lead) of the LED to the ground rail making sure to preserve the LED placement.

The PCB is held in place with a wire around the bottom half of the last rib.  Drill two small holes in the PCB just past the first rib of the bar end on either side of the shaft.  Wire the PCB in place, twist and snip excess.

Hot glue four long wires through PCB.


Step 7: Prepare slave bar end

Picture of Prepare slave bar end
Cut slot for PCB to fit snugly up to the second rib of the bar end.
Drill 13/64-inch hole for LED.

Step 8: Install LED D2 on slave

Picture of Install LED D2 on slave
Insert free end of R2 into the outside hole on the board as far as the end will reach. Solder. Do the same for the free end of the jumper.   One side will use the copper connection already on the bottom of the board; the other connection is made manually by bending the end over to the LED lead. 

As with D1, insert D2 into the bar end plug until it stops.  Fit the PCB into the slit and bend the LED leads so that they reach the holes adjacent to the free lead of R2 and jumper wires.  Solder in place.

Fasten slave PCB to bar end plug with thin gauge wire, as the master was done.

Step 9: Battery holder

Picture of Battery holder
DSCN8246.JPG
DSCN8247.JPG
Create the battery terminal connectors by coiling and soldering stiff wire as shown below.

Pass the ground rail jumper with one free end through the PCB and trim excess wire.  Solder one of the newly created battery connectors to the end. 

Pass free end of the jumper connected to the middle terminal on the switch through the PCB.  Trim and solder to other battery connector.

Secure battery to coiled leads with a zip tie pulled tight over the battery.  With the fat part of a cheap soldering iron, melt the zip tie just a bit to make corners to hold the battery in place.

Tape battery wires to zip tie.

Step 10: Master/slave connector

Picture of Master/slave connector
Measure the total length of the handlebar with a tape measure.  My bars measure 42 inches.  Add three inches for maneuvering room. Cut the two 50” wires to that length.

Solder two anchor wires to the outside pins of the 4-pin female header.

Place several half-inch heat shrink segments over the two long wires.  On the end, slide a heat shrink segment onto each of the long wires individually.

Solder long wires to the two middle pins of the 4-pin female header.

Solder two short wire segments to the outside pins of the 4-pin female header.

To relieve stress on the LED wires, heat shrink the middle wires to the outside anchor wires using the pre-placed segments on the ends of the long wires. 

Heat shrink the long wires together evenly spaced all the way back with the remaining segments.

Step 11: Program with arduino IDE

Picture of Program with arduino IDE
Finally to the Arduino IDE. 

The code can be found here: BEBL2.pde.  Copy and paste into a new project on Arduino.   If you take a look at the code, you will find that it is more complex than you might expect due to the digital filtering, without which the brake light would be going on and off constantly.  You will also see some calibration routines I used to figure out the accelerometer readings.  One funny thing about the breakout board, is that a different analog RC filter is on each axis.   So each axis behaves a little differently.  I put default values in the the code that work well with all three of the accelerometers I've gotten from pololu, but you can overwrite them using your own values or by the calibration routines.

Program the chip using a standard Diecmila or your favorite board with removable MEGA IC.

Remove the MEGA from the programming board and insert into the 28-pin socket with pin1 toward the bar end plug.

Insert battery.

Cross fingers.

Flip switch.

Congratulations if you should see a blinking light! 

If not try flipping the battery over.  Still not?  Flip switch the other way.

If it still does not work go on to the next step: Debugging.


Step 12: Debugging

Picture of Debugging
bebl_schematic.png
I was shocked when I followed these instructions and the thing worked first try.  There are several things that could have gone wrong from a bad solder joint, to a good solder joint in the wrong place.  If your light doesn't come on, to take a deep breath and avoid panic.  You've put a lot of work into this and we can figure out what the problem is.  The good news is that the schematic is simple enough to check by hand.  If you find an issue, re-solder or correct as necessary. 

Here is a series of debugging steps to consider:

1. Start at the battery.  My fresh battery reads 5.5 Volts.  Replace the battery if necessary.

2. Ensure the switch is turned on and check Accel power in.  Accel pins VIN and GND should have the same voltage as the battery.  If so go to 3. 
2.a Check that the positive battery terminal has connectivity to VIN.  If so, goto 2.b.
2.a.1 If it is not, remove the battery and check connectivity from the battery positive terminal to the middle switch pin.  
2.a.2 Check that the other switch pin has connectivity to positive battery terminal when the switch is on.
2.b Check that the negative battery terminal has connectivity to Accel GND. If so, replace the battery and start over -- you've got power to the Accel.
2.b.1 Check battery - to ground rail.
2.b.2 Ground rail to Accel GND.  If so, replace battery and start over.  You should have power to the Accel.

3. Check Accel power out.  A volt meter on Accel GND and +3.3V should read about 3.3 volts.
-- Yikes, bad Accel voltage regulator.  Replace.

4. Check that the voltage potential between ground rail and VCC rail is 3.3V.  If not, check the connection between Accel 3.3V to VCC rail.

5. Check power on MEGA chip pins 7 and 8.  They should have a 3.3V potential.  Check jumpers to central rails.

6. Check that the LED is in the soldered with the correct polarity.
Set the multimeter to read resistance.  Connect red probe to the cathode of the LED, black probe to the anode (see diagram).  You should read about 1000 Ohms resistance.  If not, flip it the other way.

7. Reprogram the chip with this line  near the bottom of the file un-commented:
  "// digitalWrite(DBG_LED_PIN, ((count % 1200) < 600));"
This sets the Arduino pin4 (physical pin6) on an off in one second intervals.  Put a volt meter between pin6 of the socket and ground.  Voltage should vary in one-second intervals.  If it does not, you have a bad LED -- swap it out.

8. If the LED blinks but brake light never comes on, check Accel pins x and z. for voltage between 0.5 and 2.5 volts. If not replace Accel.

9. If master works but not slave, recheck connections.

10.  If all else fails, recheck every connection in schematic.  Then ask me.  I'll respond to your questions.

Step 13: Installing on the bike

Picture of Installing on the bike
magnets.jpg
I puzzled over how to thread the cord through the handlebar.  Then it finally hit me: magnets!  Attached a small rare Earth magnet to the end of a long piece of string.  A larger rare Earth magnet is used to pull the smaller magnet through the bar, trailing the string behind.  This was a bit tricky.  The magnets occasionally get stuck an the brake lever stem.  A couple of tried and a pointer from my daughter to go along the side of the bar, rather than around the inside, got the job done.  When you remove the BEBL, pull the string back through for easy remounting.

If you don't have magnets, I've heard a compressor can be used to blow the string through the bar. 

Better yet, jomaro suggests using a vacuum cleaner to suck the string through:
"Whenever trying to get a cord through any type of tube, get a vacuum cleaner at the other end and it will suck the cord trough! Done!
I once succeeded to pass a cord through 15 meters of plastic pipe like this. In  case of long pipes it is better to do any type of not at the front end (or tie any light plastic part) to increase air resistance."

Post any other method you've found to work here.

Step 14: Improvement Ideas

Picture of Improvement Ideas
push_button_pwr.png
Lower power, cheaper batteries, rechargeable batteries, Hub dynamo's.

Auto shutoff.  The schematic below show how the voltage regulator circuit could be modified to allow digital shutoff (for instance when the vibrations cease for a specified duration).

Use right angle header on GS1 and GS2.  This should still fit in bar and allow easy modification of Accel sensitivity.

Or better yet, connect GS1, GS2 to digital pins for digital gain control
I'll add this to the next version for sure.  No need for this project, but the design should be as flexible as possible.

Put long cord on slave board so that master can be installed easily on different bike
This is an obvious choice.  It'll be in the next version.

Use an independent pin to control slave LED.
There are plenty of pins on the MEGA, why double up on pin4 and loose independent control of the other LED?  I've played around with this, the extra logic slows down the tracking loop.

Next up ... a printed circuit board would make this a really fun and easy project.  Let me know if your interested.  I'd like to print up a few boards.

1-40 of 58Next »
RzBo1 year ago

Hi WyoJustin,

I'm trying to make your brake system but with an other accelero (adxl335), I have change midpoint and sensitivity but i'm wondering about some calculations on the code:

- what info are down_x dans down_z ?

- what is the aim of this operation : val = -x * down_z + z * down_x;

- Why don't you only use X acceleration and trig this info ? On a bycicle you can only decelerate 'forward'? Do you have notice any false 'brake' during climbing on high grade hill ?

Thanks,

RzBo

The link to the Arduino code is broken. Any chance you can post it here?
WyoJustin (author)  atatistcheff2 years ago
still here:
https://docs.google.com/document/preview?id=1o03JNsczAHO_7AqnSu-AJvdP9GMzGC792b4w4MKlCio
ketas3 years ago
Am I the only one who looked first picture (especially the small one) and thought "Who the hell wants Arduino powered Fleshlight?"
Ryanstan1233 years ago
Hey Justin-I own a bike shop in Austin, and I would love to get my hands on a printed circuit board to show some of my customers. Is there any way I can get a few.
jomaro5 years ago
Very good i'ble. Prize well deserved.
Whenever trying to get a cord through any type of tube, get a vacuum cleaner at the other end and it will suck the cord trough! Done!
I once succeeded to pass a cord through 15 meters of plastic pipe like this. In  case of long pipes it is better to do any type of not at the front end (or tie any light plastic part) to increase air resistance.
WyoJustin (author)  jomaro5 years ago
Thanks and great idea with the vacuum.  I'll update the 'ible!

Justin
jerjod5 years ago
 Very nicely done.  Congrats on your win.  I was asked to be a contest judge for the first time, and your project was my number one pick.  Not only was it a great idea and a well written instructable, but Michael Jackson's "Don't Stop 'Til You Get Enough" put you over the top.
WyoJustin (author)  jerjod5 years ago
We were just discussing what might have put BEBL over the top!  Thanks so much, I was truly surprised and am still in shock.

Coming soon: a helmet mounted version.

Thanks again!
Justin
mikeasaurus5 years ago
*high-fives*!

Way to go winning the contest!
knektek5 years ago
ill vote for this.
dpkrmandal5 years ago
Great idea. Very interesting homemade project!
WyoJustin (author)  dpkrmandal5 years ago
Thanks for checking it out!

Justin
norrski5 years ago
I love this 'ible!
Instead of an arduino, (which I have NO experince with), would a small pressure xducer between the brake pad and its holder work to act as the switch?

... just thinkin'...
WyoJustin (author)  norrski5 years ago
Thanks norrski,
I think the best place for a switch is some where on an exposed piece of cable.  You could attach a wire that will become disconnected when the cable is pulled for instance.  Or if you could use a magnet and detector instead of a switch.

Justin

brilliant!  I like the magnet idea... probably easier for me to configure than an arduino or pressure transducer... thanks again for some great ideas!
ogama8 norrski5 years ago
spark fun sells Hall effect sensors for ~$2 which goes high when a magnent is near.  Same thing you bike computer uses. or you could use a reed switch...
ogama85 years ago
I woud totaly do this but I have bar-end shifters and you used an arduino.
macrumpton5 years ago
Perhaps I am not understanding the project, but wouldn't it just be easier to have the brakes trigger the brake lights like in a car? a microswitch mounted near one of the front brake arms would do the trick.

I like the lights in the bar ends idea, I wonder if you could do a combo brakelight/headlight and use the arduino for triggering the headlight(s) when it gets dark.
This is a great idea!. There are a couple of things you might consider.

>Are the lights visible from the vantage point of different types of vehicles? With only one LED per BEBL the range of visibility might be limited because the levels of the eyes of other drivers might not be in a direct line of sight.

>Have you considered that lights brake lights on most vehicles are located on the rear of the vehicle? Brake lights located on the ends of the handlebars might give a false impression of location to other drivers on the road. Remember, your safety is important. A slightly different example: remember when the brake lights of vehicle were located on on the bumpers or vertical trunk area? I believe the rear window brake light was an addition that greatly improved the braking visibility to other drivers.

On the other hand, a BEBL is probabaly a good idea to keep so that when other vehicles draw near to the side of your bike, they can see you beside them.

>Dynamo vs battery - why not both? Recharge the battery with a dynamo.
WyoJustin (author)  playinmyblues5 years ago
playinmyblues,
Thanks reviewing this instructable.  This is actually a early prototype of the SharkFin helmet mounted brake light, which will be visible from the back of a large pack of riders.  I like the bars in the mean time to provide a ready made, free project case.

I agree, if your going to use a dynamo, use it to charge a battery!
dynamo + battery = awesome

Justin
ghostWolf595 years ago
Hi,
Instead of powering it with a battery - why not use a small dynamo/generator that is powered by the bikes movement ?
- after all, this really good idea would only make real sense if/when the bike is moving.

Removing the need for a battery (that most likely have gone dead by the time you need it) would make this practically maintenance free.

You should try to make this a commercial product - lots of potential, mate !
yes, but then, when you brake, it would stop charging, and the lights circuit would shut off due to lack of electricity, which would defeat the whole purpose. it would only work if you are moving, but if you are slowing, it would not work as efficiently.
Braking would make it stop though - your still moving.

I also think there is enough gadgets around that would allow enough charge to be stored so even if the bike comes to a stop it will still work for x time.

The point I tried to get across is that the battery would be the weakest link - try to find a way to make it almost maintenance free.

cheers
yes, now that I think(wow!) you could have a supercap or something.
yepp, and if you tie the supercap to a small generator (solar is popular to :) and remove the need for a battery you would be able to store a lot of power - practically maintenance free, mate!
I guess the little wiring needed easily could be sitting inside a standard bike frame - no exposed wires.

I think you should try to make this commercial - if nothing else you ought to protect the the idea - then sell it to some rich Chinese company for big $$$$ - When you do I wouldn't mind getting a share :) - At least so I can send my kids to a good school or something :)

cheers
lol, I know right? big $$$$$$ :)
...and here's another novel expansion to this - why not connect it to a relay that allows the lights to flash - like a warning hazard
- You could create a small semi flexible rubber/plastic extension that would fit into a standard handle bar (standard bar i.e a straight one commonly used on most street bikes (non racing ones)
The bend should be pointing backwards once its inserted into the handle bar - Alternatively this could also be a complete replacement hand grip- I've tried to draw a rough sketch on what I am thinking.


WyoJustin (author)  ghostWolf595 years ago
ghostWolf59 --

I like your idea of using a dynamo.  A friend had the same suggestion and I included it in the improvements section with a link to this power generating hub.   This would be a great project to add this to BEBL!

Justin
robbied5 years ago
Using the system you have created, and the single lithium charging board from sparkfun, you could create a system for headlights and brakelights that can be charged via USB (or wall wart adapter(or). I have some 1 and 3W cree type LED torches that make good headlights, I just need to work out how to make them flash. Not a simple flash, but push the button once for full power, push again for flash etc.
Cool idea.  How does it respond to irregular pedaling, such as pedaling slowly up a steep hill?  Also, I think that it is debatable as to weather it should blink when not braking.  If they are intended for use within a group of riders to warn when slowing down, then I think that they should remain completely off unless slowing.  If  they are intended as a warning to motorized traffic, then the blinking is warranted.  
WyoJustin (author)  claytonpbarrows5 years ago
claytonpbarrows,
Thanks, that's the best question I've had on the BEBL. There are actually 4 IIR filters running at about 650 Hz, all on that micro! Two really low pass filters (X1 & Z1 -- intrack & up) track the accel due to gravity. I know the unit is to be fixed to the bike so I don't expect any really rapid changes in the down direction relative to sensor. Slow changes like transitioning from uphill to down hill are in the pass band.

The other two low pass filters (X2 & Z2) filter out road vibration, bumps and accelerations from peddling but braking is in the pass band.  This causes a slight, but acceptable delay in the trigger.  You can probably trick the brake light into coming on with slow, hard pedaling.

Suppose we assume that down is given by the unit vector [X1, Z1], then forward will be orthogonal ~ F = [-Z1, X1].  We measure breaking by dotting [X2, Y2] against F.
B = [X2, Y2] . F.  If this signed quantity exceeds a threshold of about .04 Gs we turn on the brake lights.  Because it is signed we can distinguish between lowing down -- braking and speeding up -- accelating.

You may be correct about the flashing when not braking.  Since this is still a proto-type I like to know that the unit is at least powered up.  I could add a jumper for flashing vs not flashing.

Thanks for your comments!
Justin
Very well done instructable.  First time I've seen one with debugging instructions!

I'd like to make one that attaches under the seat, like most bike lights.  This would make switching back and forth between bikes a snap.  I guess you were trying to avoid the issues with building/reusing an all-weather case that could be needed there.
WyoJustin (author)  SiliconFarmer5 years ago
SiliconFarmer,
Thank you very much.  I'm glad you noticed the debugging section.  You shouldn't have much trouble with your seat post mounted version.  The bar ends were just easier and I didn't have to tear up a functioning light.

I'd like to get around to making a version that is helmet mounted which would be even more portable.  Even more hardware is required for this solution.
Justin

smandal5 years ago
This is cool. compact and useful.  I like to see with power generated or batteries charged by bike movement.

I like the stepwise video ...
WyoJustin (author)  smandal5 years ago
smandal,
It seems like we are converging on to versions: a dynamo powered commuter version and a battery powered version.  For the battery powered version, it seems like there is enough room to mount a mini usb port to charge a battery without dismounting the unit.

Thanks for commenting!
Justin
joe5 years ago
Very neat.

-Joe

WyoJustin (author)  joe5 years ago
Thanks Joe!
You know what would be safer? If large groups of people without lights or reflectors didn't ride at night on a dark trail, on the wrong side of the road!
dacarls5 years ago
I had to watch the video twice to figure out where the lights were mounted.  Ya cannot see them unless you know. Accelerometer idea is cool, 1 LED each is a bit lame.
1-40 of 58Next »