Arduino Bike Computer
I’ve been really getting into cycling again the last few weeks, I changed the tyres on my mountain bike and I wanted to see if it had made a difference to my speed. The easy thing to do would have been to go and buy a bike computer, but where’s the fun in that? Instead, I opted for a magnet attached to the front wheel to trigger a reed switch mounted opposite on the fork (although a hall-effect sensor would have worked just as well) to control an Arduino connected to an LCD screen.
The principle is simple, the magnet was cable-tied to the reflector on the front wheel, which was 9.5 inches from the axle, and every revolution at that point meant that the bike had travelled 59.69 inches. This was used to calculate the miles per hour and total distance travelled.
There are quite a lot of wires for the LCD, which makes it hard for me to write up, but this tutorial from ladyada good for reference. One of the trickiest parts was working with floating point numbers and sending them to the LCD screen, I resorted to using this bit of code from mem.
I wired it all up and stuck it inside a cardboard box that I had cable tied to the handlebars, which got some funny looks from people when I rode past, but it got the job done! The Arduino was powered from a battery clip with four AA batteries. There are still some minor issues with the code and it’s still a work in progress, but it worked fine when I rode it along side a car and read out the readings. The source code is attached.



Comments [2]