Skip to main content
Escape Characters

When Config Files Have Dire Consequences

So, I started a project. Another project.

A year or two ago I got an exercise bike. It was from Costco, was cheap, and was made purely of metal, had a fixed gear (no ability to stop without the wheel stopping as well) , and with no electronics of any kind. This was pretty ideal, as I usually find the heartrate monitors and such distracting, disheartening (only 100 calories? etc.), and inaccurate.

What I do like doing while biking, however, is to watch videos. In the middle of winter, with no TV, this is sort of how I survive atrophy. The problem being, however, that when watching videos, I'm usually more interested in what I'm watching, and will stop biking for 10-20 minutes before I notice I'm not doing what I should be doing.

What I wanted to do was find a way to hook up my exercise bike to my computer, and have the computer pay enough attention such that it would only play video normally if it found that I was biking a reasonable amount. When I wasn't biking a reasonable amount, then it would be able to alter playback such that it was frustrating enough for me to bike more.

For the software component of this, I chose VLC Media Player (VLC) in combination with a Perl script I wrote to communicate with the bike and the display. VLC, aside from being a versatile and well-supported media software, has a number of interesting interfaces. For instance, you can tell it to run a web server, and control it via a web browser, or even more simply, open a port to listen on, and listen for simple text commands. For the first component of the project, I elected to use the latter. This interface allows control over basic functions (play, pause, message displays), and also provides for control over playback speed (faster, slower).

For the hardware component, I ordered an Arduino microcontroller educational start kit, a couple of Reed switches, and a magnet. Taking notes from this guy, I put together the Arduino to try to detect the magnet attached to the wheel every 10 milliseconds, and only issuing a "I saw the magnet" message to the computer once it no longer sees the magnet.

After a period of programming, testing, and finding random boxes in my closet to properly mount the thing, I came up with this:

DSC_0449.JPG

Watching an episode of Farscape last night, it seems to work. I had it accurately calculating RPM based on the controller software, and correctly controlling VLC to slow down playback when I reached below 70%, 80%, or 90% of what I should be, and pausing if I go below 50%.

Ideas for future revisions:

I also need to find a better, quieter fan for my downstairs. With zero airflow down there, there's a pretty big threat to the Arduino controller from water damage.