This project uses an Accelerometer to detect when you are leaning left or right. Depending on if/where you are leaning, it will flash LEDs on the right or left of the bike's rear. Powered by an Arduino and a 12v battery pack (my case 8 AA Batteries). I have made a video on it below.
Here is the code you'll need to build your own.
What You'll Need
- Arduino Uno R3 OR Arduino Micro
- 2x RGB LED
- Jumper Wires
- VCNL4010 Proximity/Light Sensor or Push Button
- ADLX345 Accelerometer
- Breadboard
Step 1: Soldering the Accelerometer Headers
The first thing we have to do is assemble the accelerometer. Put the headers in the breadboard, apply solder and your done.
Image credit: Adafruit
Step 2: Wire it up.
Using the video above, or the wiring diagram below, wire the accelerometer, LEDs, and Arduino.
Step 3: Program the Arduino
Use the code attached below (Latest version) to wire the Arduino up.
There are these two lines which may need adjusting, line 161 and 162
if (event.acceleration.x > 2.5) { lBlink(); lBlink(); } //see if we are leaning to left, if we are, blink if (event.acceleration.x < -2.5) { RBlink(); RBlink(); }// see if we are leaning to right, if we are, blink
Keep the majority of the code the same, and adjust the 2.5 to whatever sensitivity you want (note, you need to keep the minus on line 162)