For a while I had wanted to put an unreasonable number of lights on the bicycle I use to commute to work, but sometimes it can be hard to give yourself the push that is needed to start work on a personal project like this. I already had some clip on lights that did a fine job of illuminating my path and indicating my location to all the vehicles trying to run me down.
One day while my bike was parked outside of a grocery store the boring basic safety lights were stripped from my bike. I returned to my bike and realized that I was now completely at the mercy of the eyesight of the operators of the large metal boxes flying around the streets of San Francisco. I quickly biked home as the sun set, dodging the cars and trucks that had completely zero ability to see my unlit bicycle whatsoever. I made it home safely and full of motivation to complete the Disco Bike.
The project was pretty simple, zip tie a bunch of serially addressable LEDs to my bike and hook them up to a teensy micro-controller. These serially addressable LEDs are awesome for projects like this because the color and intensity of every individual LED can be controlled. To power it all, I Velcro’d a 32,000mAh USB battery pack to the bike. 32,000mAh is a lot. A typical phone battery is only around 2,000 – 3,000 mAh. The pack can power the bike lights for about 5 days on a single charge.
I also made an attempt at waterproofing everything a bit. The micro-controller is in a plastic box I attached some waterproof cable glads to. The LED strips have a silicone covering and some sealed caps on the ends. I don’t particularly trust the waterproofing enough to ride in the rain, but honestly who wants to ride their bike in the rain. The bike handles light drizzles, water puddles on the ground, and also dirt quite well though.
The most fun part of this project was making the visualizations. They are all coded in C++ that runs on the Teensy. The video below shows some of the patterns that I have created. They are all stored in the memory on the micro-controller which randomly loops through all the different patterns.
It’s always possible for me to add more patterns to the bike too; however, having to make them in c++ is somewhat annoying and often requires being a little clever. For instance, there is one visualization you can see in the video where some blobs move across the LED strips. When I first approached the problem I went the rote way of creating arrays to store the position and color of all the LEDs in one blob. I then had a loop that incremented the position over time. This ended up getting really annoying to integrate, a lot of cases like the blobs reaching the end of the strip, the number of blobs changing, adding a fade to the front and end of the blob starting to make the code hacky and ugly.
I then had a thought, the effect I really wanted was a sort of wave like train of blobs, it reminded me a lot of a sine wave. This caused me to recall all the great mathematical tools we have to model moving waves through time and space. This thought allowed me to cut down the complexity of the code greatly. Instead of having to essentially manually program things like the length, size, and speed of blobs, I just made the LEDs light output a sine function over position of LEDs and time. By then changing things like the wavelength, amplitude, velocity, and phase of the waves I could quickly and easily create any blob pattern I wanted. Neat! The thought could also be extended to the color of the lights too with the hue of the LED also being integrated into the wave equations that determine what the LEDs do.
In the future perhaps I’ll find some more cool math I can use to rapidly make more interesting visuals.