All my previous jobs were based in the town I live in so I used to be able to cycle to work, with my current job it’s far enough away I can’t reasonably cycle to work. As such, and as the company is jokingly referred to as the “Cake-apult” for the amount of cake we seem to go through, my weight has inevitably increased. To try and remedy this I’ve recently purchased a DeskCycle. I would like to give a walking desk a go at some point but this seems a far easier solution and as sitting down for extended periods is linked to many problems I figured it worth a go.
It arrived earlier this week and I managed to cycle while sat at my desk for over two hours each day, I felt knackered by the end of it so it was certainly having an effect! The only issue for me is the speedo. The creators of DeskCycle designed the device such that the speedo is accurate when the resistance is set to maximum, this results in the speed and calories calculated too high if you have the resistance set lower. They provide a calorie calculator to provide a more accurate set of results once you’ve punched in the values your speedo provides.
On to the how;
Looking at the bike it looked like the speedo works in the same way to the speedo on my road bike, a switch is closed once per revolution of the flywheel. I connected my multimeter to it in continuity tester mode and it confirmed my theory. As the bike uses a 3.5mm headphone jack for a cable it was simple enough to make a cable to connect to the header on my Arduino.
The cable has a 3.5mm headphone jack at one end, tip and ground in use, and a pair of header pins at the other. Connected to the Arduino via a bit of breadboard, I’ve connected using pin 7 in pullup mode with the other end of the switch connected to ground.
Once connected I’ve followed the timer tutorial provided by Amanda Ghassaei to calculate the RPM by counting the interval between revolutions. One thing I learned is that the millis() function uses timer0 internally so if you want to use that function and a timer interrupt then use timer1 or timer2.
Next up is a simple application that reads the RPM and calculates speed and distance to display it on my PC to start with. I’m intending to add some cool functions like map integration to do virtual challenges such as Lands End to John O’Groats and similar which should be good for a laugh.
Also, this same code will be the basis of the digital speedo adapter for my Mini so two birds with one stone! As practice for my Mini speedo, and more practice for stuff for work, I’m going to write it using C# and Unity 5.
Update: The Unity part is done, more information here.