This Arduino bike lighting project upgrades your bike’s light and takes it to the next level so that the backlight of the bike automatically notifies others when you are turning.
We used Arduino UNO as our main microcontroller (use Nano or Pro mini to shrink the size if needed), Accelerometer to detect the 3 axis directions and Neopixel to blink the LEDs in the corresponding direction of movement.
Hardware components:
Software components:
Arduino IDE
Read Arduino Basics (Level: Beginner)
1. Define the range of the results out of the accelerometer
This step is where you should find out the X, Y and Z direction of left and right. Take note of the position of the accelerometer while testing, since you have to place the sensor in the same position later on the bike.
You can simply upload the .ino sketch to your Arduino and open your Serial monitor and notice the flow of numbers of the 3 axis (X, Y and Z ). Make sure that the baud rate is set to 9600 so you can see the actual results.
These numbers correspond to X, Y and Z respectively, experiment with the change of numbers when you turn right and left and when you keep your Arduino bike lighting straight forward.
These were my values when I connected a pullup resistor of 330 ohm on pins A4 and A5; you will get different values if you use other resistor values.
2. Create your own Arduino bike lighting pattern with the addressable LEDs
One of the advantage of these pixels “WS2812b“ is that they are addressable which gives you a wide range of getting creative ideas of lighting. I’ll discuss how to build your own pixelstick using ws2812b LEDs in a follow up post.
I have only chosen 2 colors (green and red) for my Arduino bike lighting system, but you can add more colors to your pattern by mixing the value of RGB as shown here.
Get creative with it!!
3. Connect the two codes together
Simply connect the codes together, identifying which pattern to start with for each direction.
Sketch