this instructable shows how to connect an accelerometer to an arduino to sample motion and trigger a light. in this case I am connecting an LED brake light through a relay. my goal was to create a device that I can attach to the back of my trailer and have brake light simulation based on acceleration/deceleration. I realize that this device could also be attached to a bicycle as a self contained brake light. it doesn't work as well as a brake light connected to the brake lever but it does ok.
a kit of parts can be ordered from Jameco: Passive Brake kit
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Layout and Wiring
here is the basic layout of the assembly. it uses an arduino uno and a 3-axis accelerometer (even though I only sample one axis). the digital signal generated from the arduino will be used to trigger the relay or could just be used to trigger an LED.
Step 2: Reusable Accelerometer
I like to use headers for the accelerometer. it is easier to reuse the components. if you are making a device to use, you may want to solder the wires directly.
Step 3: Orientation of Axis
this assembly will sample the forces on the z axis. from the diagram on the accelerometer, the z axis goes through the board. when the accelerometer is mounted in a brake light housing, the board should be oriented to stay as vertical as possible. the button connected to the digital 13 pin of the arduino will allow you to calibrate the brake light after it is mounted. by default the program uses a trigger range between -30 and 30. if the axis is off center even slightly, this default range may not work well. after mounting the assembly, push the button and the light will flash indicating that it has stored the appropriate trigger range. you can test the calibration range by tilting the assembly so the accelerometer board is horizontal and then back to vertical.
Step 4: Source Code
the source code comes mostly from the wiki for the accelerometer board:
I have documented the parts that I added for triggering the relay and the calibration switch
Step 5: Packaging
I have tried this with two types of LED brake lights. the square light has enough room for the entire assembly using an arduino pro mini. the oblong LED brake light has room to attach the components to the back but may need more packaging to keep it reliable.