About this project
This is a very simple and easy-to-build project that provides a sensor on the pedal crank of any exercise bike and generates keyboard output triggering Google Maps Street View to advance via the up arrow key. In my design, you pedal the crank five times, and then the Street View receives an up-arrow command that advances you to the next Street View panorama. Steering is not included, but it should be possible to easily add it via switches attached to the hand grips on your exercise bike.
The recent release of the Arduino Leonardo allows this project to be constructed with a minimum of effort. The Arduino is a popular miniature computer capable of being programmed from your desktop or laptop, and it can run on its own after you program it and disconnect it from the PC. It has a number of input and output pins, including both digital and analog inputs. It is very popular with the DIY crowd and has been integrated into hundreds of projects. This is my first original project using the Arduino.
The Leonardo, unlike the other flavors of the Arduino (there are many variants), has a built-in keyboard and mouse emulator that allows the Arduino to mimic the behavior of a USB keyboard or mouse.
This article was first published on Low End Mac and is repeated here with the author's permission.
Images
Other materials
- Arduino software (latest version)
- Any Google Maps Street View compatible computer (I used a MacBook Pro, but it should theoretically work on almost anything).
- Any exercise bike with about 2" clearance between the pedal crank and the housing.
Note on Arduino Leonardo:
This version includes headers, which are small plastic extenders from the board allowing you make connections simply by plugging wires in the holes of the header. If you intend to solder your connections get the "without headers" version, which is slightly cheaper. Please note the Arduino Uno model sold in Radio Shack stores is not the right one for this project and will not work. You have to have an Arduino Leonardo.
Arduino Software - Google Maps Street View
Building the Interface
Next, you will need to interface the Arduino with your computer. Connect the USB cable from the Arduino to your computer. On a Mac, the interface step simply involves closing the Unrecognized keyboard dialog that automatically pops up. It works "out of the box". Detailed instructions for how to accomplish this for other computers are posted online.
Next, you will need to attach the magnetic reed switch to the board. The switch is "ON" when the sensor is near the included magnet. It triggers within about a quarter inch, so it's pretty tolerant of things that don't quite line up. Put one lead of the magnetic reed switch in the hole marked D2 and the other in +5V on the other side of the board. You will also need to put one of the 10K Ohm resistors in the same pin 2 hole and push the other end into the GND connection on the board.
That's it for the circuit. Now download and install the Arduino software: download streetview.txt from the Files section or copy the program file located in the "Code" section below.
You can either paste the code into an empty window (called a "sketch") or open the file with the file dialog. Then press "upload." That's the right-hand arrow button in the sketch window.
You should see LED lights blinking on the Arduino for a few seconds. After a few moments, the status line at the bottom of the window should say Done uploading.
Be careful not to trigger the magnetic switch now, because your keyboard will emit up-arrows in whatever application is in the foreground.
Testing the Interface
To test your setup, open a word processor document and enter a few carriage returns. Wave the magnet near the sensor five times, and you should see the cursor move up the page one space. If that works, you are good to go.
If you want to adjust the number of cranks it takes to trigger an advance in the map, change the line that reads const int crankratio =5; // number of pedals that invokes a single "up arrow" to whatever value you want.
I am not going to go into a detailed breakdown of the software here, but here are a few things you might like to know. The ASCII code for up arrow is 218. If you have a computer that maps a different code to up arrow, that number would need to change. I have no idea if that will be required on a PC or other machine. My guess is probably not.
Also, if you find it is advancing with erratic numbers of triggers - meaning sometimes you pedal once and it advances and sometimes you pedal 3, 5, or more times - this is probably due to the switch not being debounced. When a switch is pressed, there are sometimes microsecond intervals where the signal is activated and then disconnected as the switch slowly makes contact. (Slow in the sense of high speed electronic circuitry.) This program provides a short delay for software-based debouncing and makes sure the switch is still closed after a 3 ms interval. If it doesn't work consistently for you you could try making that "delay (3)" a little interval longer.
Using the Interface
I attached the sensor to the bike's frame with Velcro™ and the magnet to the inside of the crank arm near the pedal. You might need to make some adjustments to bring the magnet as close as possible to the sensor without running into it. My experience is that the sensor was pretty forgiving - it isn't even lined up quite straight on mine, and it works.
Next, with the sensor in place, the software loaded (it runs automatically), and the board plugged into the computer you intend to use, set up Google Maps with Street View and activate fullscreen view.
You can use the built-in Maps view to save where you left off if you want to keep going. It is my intention to virtually ride all the way across the country in Street View. I admit this will be much easier than actually riding across the country, but even this should provide me with a lot of exercise and some fun exploring small towns and various sights along the way in Street View. I imagine the ratio isn't constant throughout the country (distance covered vs. number of panos taken by the Street Map van), but this is a start.
Comments