When ridding for your commute or for pleasure, being visible on the road is always a nightmare, as either your bike light system in daylight is not visible, or because drivers never known when you turn in night conditions.
The Blinky Bike project is the ultimate solution to add light system to any Bike, (and electric Bike) using a 5V power bank or the onboard bike Battery. It relies on NeoPixel LEDs (WS2812) flexible stripes, for the Front and Rear. The system based on an Atmel ATtiny 85 micro-controller, and allows different light modes that can be selected using two water proof switches (One for the Left hand and one for the Right hand).
The system is based on a Front LED flexible stripe and two Rear LED Flexible Stripes, one for the Left and one for the Right indicator. The Front and Rear LEDs stripes are composed of a total of 30 LEDs, 8 for the Front and 11 for each Rear stripes.
When riding a bike at night, having fix light color is not the optimal solution to be visible by drivers. Therefore having some flashing, blinking mode for the lights gives more visibility. When light is On, the Front stripe displays a fast blinking animation at a frequency of 10 Hz or so. When turning left or right, the rear visual animation is orange and blinky.
The device Left and Right buttons are the only interface with the system allowing to :
- Turn ON and OFF the light system
- Turn Left and Right indicator
As shown in the video, the waterproof buttons are use to drive the light indicators.
Step 1: Power Consideration
The system is designed to be power friendly with the e-Bike battery, as the battery might not be able to provide the full power required to have all the LEDs turned on at the same time. As the NeoPixel RGB LEDs (WS8212) consumes 20 mA per color channel, with a total of 60 mA (3 channels * 20 mA) when the LED is turned full bright White color (Red = 255, Green = 255, Blue = 255). The challenge is to not be over 500 mA (power limit supplied by the Battery on my e-Bike). I have applied a secure level set to 450 mA maximum. Leading then to a limit of 7 LEDs active at a time. Having only 7 LEDs is really limitating for a bike light system, so the solution is to multiplex the LEDs and ensure that only those 7 LEDs are on, while all the others are off. If the multiplexing switch is performed fast enough, it should be possible to make it not visible for a Human eye. Therefore, the ATTiny firmware is taking care of the current limitation by switching on and off the LEDs, remaining only 7 LEDs on at a time, giving a maximum power consumption for the LEDs of 420 mA.
Step 2: Build the Hardware
The hardware is minimalistic as the Neopixel and ATtiny are embedding all the discrete components that you normally use to drive RGB LED.
The BlinkyBike system is built using the following hardware :
- 1 x ATtiny85
- 1 x 8 NeoPixel LEDs Stripe
- 2 x 11 NeoPixel LEDs Stripe
- 3 x 380 Ohms resistor
- 1 x 10 kOhms resistor
- 1 x 1000 µF capacitor
- 2 x water proof switches
You won't find any PCB layout, as I'm using through hole prototyping board, developed with Fritzing software.
The BOM (Bill Of Materials) is really cheap, as you can build your own for less than 30 Euros.
Step 3: Build the Software
The ATtiny 85 is a really cool Micro Controller that have 8 KB of Flash and 512 B of RAM to run any kind of C or C++ software. This gives some space to run a simple software and for this reason some optimization are required.
The project has been developed in C++ (C++11) in order to reuse and give more flexibility in case of development of new features. It is required to use the VisualMicro extension for Visual Studio 2013/2015 in order to build the project. AdaFruit is providing a library to drive the Neopixel devices, that you can directly integrate in your Arduino IDE. But this code has been designed to support various modes in order to address major use cases. The BlinkyBike project source code repository is containing an optimized version that works only with the selected Neopixels and might not work if you choose a different one. The Neopixel device requires specific timings that can't be reach when using the ATtiny 85 in 4 MHz (its default configuration) and therefore requires to use the 8 MHz mode of the ATtiny. So it is mandatory to burn the correct fuses in the ATtiny before deploying the firmware. This can be done from the Arduino IDE by selecting the ATtiny 85 target and selecting the clock frequency to 8 MHz (internal).
To build the Software you need :
- Project source code from github.com
- Visual Studio 2015 (works with Community Edition)
- Arduino Plugin for Visual Studio from VisualMicro
- Arduino IDE (only for the compiler)
To install the development environment, VisualMicro user guide is clear and well documented, this is a good starting point to have your system ready.
Install the Arduino IDE application, and launch the application. You first need to add the support of the ATtiny familly as by default only Arduino based platforms are supported. From the File menu, select the Preferences submenu, and then find the “Additional Boards Manager URLs” field near the bottom of the dialog. Add the following url :https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json You can then validate and close the preferences dialog box. Then from the Tools menu you have to :
- Select ATtiny as Board
- Select ATtiny85 as Processor
- Select 8MHz (Internal) as Clock
- Select USBtinyISP as Programmer
Close the Arduino IDE application and install the Visual Micro plugin for Visual Studio. Launch Visual Studio and open the BlinkyBike.sln from the project folders. On first usage of Visual Micro, you have to configure the various parameters of the plugin.
- Select the version of the IDE you install
- Enter the path to the tool installation folder
Then validate the configuration window and access the Visual Studio IDE. From vMicro menu :
- Select ATtiny w/ ATtiny85 as Board
- Select 8MHz (Internal) as Option2
- Select USBtinyISP as Programmer
The development environment is now ready for building and flashing, so use the flash menu to burn the software onto the ATtiny 85 micro controller.
Step 4: Mount the System on the Bike
Left and Right Buttons
The Left and Right waterproof buttons are the interface for the BlinkyBike Light System management, as described earlier. It is suggested to mount them close to the Grip and Shifter to avoid ridding distractions. So for this reason, I mount them next to the shifter screw, using a stainless and steal pad as illustrated on the first fourth pictures.
Front and Rear LED Stripes
To ensure a good visibility of the light, I would suggest you to stick the stripes on the Frame of the bike. For the Rear, you can use the rear frame parts that are holding the rear wheel, there is usually 15 to centimeters free, between the brake and the wheel bolt. For the Front, the head tube is the ideal spot, but you have to ensure that no brake cable is hiding even partially the LED stripe.
The PCB is small enough to fit in an aspirin tube, that have hermetic cap. Only four holes are required to get the buttons, LED stripes and power cords to get in. To maintain the packaging hermetic, then you can use hot glue inside the cap.
Once done, and enclosed correctly the tube is small enough to get fixed under the handlebar using plastic ties.
The device is 5 Volts powered, so a USB Power Bank of 10000 mAh is a perfect solution for 3 weeks of daily commute. You can find small devices at you favorite store.