Introduction: Automatic Bike Lights

About: Creative Technologist.

It's funny how small things sometimes can be so hard to remember. Stuff like watering your plants, putting your phone in silent mode during a meeting and locking the bathroom door.

Plants may die, colleagues may glare and the embarrassment of bathroom blunders may wear off. But there are situations where those small errors can be seriously bad. A small, but potentially fatal error, is forgetting to turn your bike lights on, and drivers failing to see cyclists is one of the most common reasons for bike accidents.

This tutorial goes through how to modify a taillight to turn on automatically when you get on your bike and turn off when you stop. Give your brain a rest and let the wonders of technology take responsibility for your taillight!

Step 1: Get the Parts

We will be using the LightBlue Bean to control the taillight. It's an Arduino compatible microcontroller that is programmed completely wirelessly.

The taillight is from Portland Design Works. It's not the cheapest one on the market but it's really bright and also has room for putting the Bean in it. We will use the Bean's built-in accelerometer to monitor when the light is moving and to simulate pressing the button on the taillight to turn it on and off.

This is what you'll need:

Tools:

  • Hacksaw
  • Soldering iron
  • Screw driver
  • Needle-nose pliers

This is what the final wiring will look like:

taillight-fritzing

Illustration made using Fritzing

Step 2: Cut the Bean

taillight3taillight4 copy

To fit the Bean into the taillight we need to give it a bit of a haircut. Use a small hacksaw to cut it just under the the digital pins.

Remember to clean off the metal shavings afterwards!

Step 3: Remove Battery Pack

taillight5

Use the soldering iron to remove the battery holder on the back of the Bean.

Step 4: Connect the Bean to the Button

Open up the bike taillight and take out the small board that's laying inside.

taillight1

On the board, there's a button that turns the light on and off. By connecting it to digital pin 0 on the Bean and setting it to output and LOW, we can simulate pressing it down. If we then set pin 0 to an input we not only “release” it but allow the physical button to once again function normally.

Solder the wire on to the top right corner of the button. Be careful so that the solder doesn't touch the metal chassis around the button. Solder it to digital pin 0 with the 1k ohm resistor in between.

taillight2

We used magnet wire in our taillight but normal wire should work fine too.

Step 5: Make the Low-pass Filter

In the code we need to know if the LED is turned on or off. The problem is that the taillight has three different modes: one solid mode and two where it blinks with different frequencies.

By reading the PWM signal sent from the chip on the taillight board we can see which mode it is in. The only problem is that the two blinking modes give inconsistent readings. To smooth the PWM signal we make a low-pass filter using a capacitor which will even out the peaks and dips to a more consistent signal.

Solder the 1M ohm resistor to the bottom end of the resistor on the left of the taillight board. Solder the capacitor to the end of it, with the other leg connected to the the bottom part of the button. Also solder a wire at the same place and then solder it to pin A0 on the Bean.

taillight7 copy

We connected an oscilloscope to the taillight to see the difference before and after the low-pass filter. The top curve shows the unfiltered signal and the bottom one after it has been through the low-pass filter:

taillight6

Step 6: Power the Bean

Solder a wire from the plus pin on the taillight board to BAT on the Bean and one from the minus pin to GND. The Bean will now be powered from the same batteries as the LED.

taillight7

Step 7: Put It All Together

Place the Bean behind the reflector, in the same way as the image below. The orientation of the Bean is important since we will monitor which direction the taillight is in to prevent it from turning on if it's just laying on your desk. Use sand paper to trim the Bean a bit on the top if it doesn't fit.

taillight8

Put in some soft styrofoam or similar to make sure that the Bean doesn't scramble around.

Step 8: Code

Upload this code to the Bean.

If everything goes well you should now have a bike light that turns on and off when you move it and it's in an upright position.

This is still just a prototype but I've used it on my bike for a couple of days and it's working just fine! A nice feature to add would be to add a light sensor so that it only turns on when it's dark. What features would you like to add if you were to make your own taillight?