Today I decided to use my Arduino decimilia and Processing to build a very simple visual speedometer for my indoor workouts. I hope to improve on it over time, but here it is in its most basic form.
The setup couldn’t be simpler: Arduino is plugged into the USB port on my Mac, and the two wires for the reed switch on the rear wheel (pilfered from an old bike computer) are plugged directly into digital port ’0′ and GND respectively. Whenever the magnet comes within range of the sensor, Arduino receives a ‘LOW’ on port ’0′. I ‘debounce’ the signal to make sure we don’t accidentally get more than one ‘LOW’ signal at a time, and then pass along a BYTE through the USB.
On the other end of USB, Processing is listening for BYTE’s, and whenever it gets one, it records a time-stamp, and then waits for another pulse. Once it’s got more than one pulse, it can start tallying up a speed. I found the speed readings to be undesirably noisy, so I added some smoothing to the equation by doing a moving average [thanks, Tim!], and then weighting the average so that the most recent reading is worth the most, and the oldest is worth the least [thanks, Dad!].
Don’t take my word for it! Try it for yourself:
|
Adam O'Hern is an industrial design consultant specializing in visual brand languages, and has designed products ranging from laptops to power tools, classroom toys to bathroom fixtures, and robots to lint rollers. He has published with 3DWorld Magazine, CGTuts+, and Luxology, and works with Josh Mings of SolidSmack.com on EngineerVsDesigner.com. |






