A couple years ago, I created a dynamic bike headlight with a Raspberry Pi and a small, battery-operated projector. I’ve been eager to explore what else I could do with a projector and a Raspberry Pi on my bike, so I created the Cycle Chaser.
Made purely for fun, the Cycle Chaser projects animations behind you onto the ground when you ride at night. The faster you go, the faster the animation runs. When you slow down, so does the animation. Of course, you can customize this project to suit your own purposes by changing the animations. You can also dive into the code and change the behavior based on your speed. Perhaps the flames behind you grow when you go faster? That’s all possible with some clever coding.
The important pieces of hardware are the battery-operated pico projector, which gets its video from the Raspberry Pi. The project code is written with the help of openFrameworks, an open source C++ toolkit for creative coding. I love openFrameworks because it can be used to develop for many different platforms: Windows, Mac, iOS, Android, and of course, Linux. The developers of openFrameworks have done a fantastic job of supporting the Raspberry Pi, so getting up and running is mostly painless … it just takes a bit of time.
When you use openFrameworks with WiringPi, a Raspberry Pi GPIO library, you can read and write to the pins right from your code. In this project you’ll connect a Hall effect sensor, which can sense when there’s a magnetic field nearby. With a small magnet attached to the wheel, the Hall effect sensor will be triggered by every revolution of the wheel, and the code will display the next frame of the animation. This means that if your wheels are going at 60 RPM, your animation will play at 1 fps.
After you get it up and running, I encourage you to tinker around with the code. If you’re familiar with Processing, you’ll find the openFrameworks paradigm to be mostly familiar, but there are a few things that will take some getting used to.
Most importantly, have a safe and fun ride!