Things used in this project

Hardware components:
Magnetic reed switch
USB to micro-USB cable or adapter
A000057 featured
Arduino Leonardo
Mfr 25frf52 10k sml
Resistor 10k ohm


arduino_software___google_maps_street_view.Plain text
Exercise Bike Interface to Google Maps Street View
Based on Keyboard.Message Example Program.
 Sends a text string when a button is pressed.
 The circuit:
 * Magnetic reed switch attached from pin 2 to +5V
 * 10-kilohm resistor attached from pin 2 to ground
 created 24 Oct 2011
 modified 27 Mar 2012
 by Tom Igoe
 modified 24 June 2012
 by Jeff Adkins
This example code is in the public domain.
 //initialization of constants

const int buttonPin = 2;          // input pin for pushbutton
int previousButtonState = HIGH;   // for checking the state of a pushButton
int counter = 0;                  // button push counter
const int crankratio =5;          // number of pedals that invokes a single "up arrow"
int debounceFlag1 = 0;            // debounce flag 
int debounceFlag2 = 0;            // debounce flag
// The debounce flags are two separate magnetic field inputs taken one after the other.
// if they match, then the switch is assumed to have actually triggered.

void setup() {
  // make the pushButton pin an input:
  pinMode(buttonPin, INPUT);
  // initialize control over the keyboard:

// Main Loop
void loop() {
  // read the pushbutton:
  int buttonState = digitalRead(buttonPin);
  // if the button state has changed, 
  if ((buttonState != previousButtonState) 
    // and it's currently pressed:
  && (buttonState == HIGH)) {
    // set debounceflag1 = buttonState
    debounceFlag1 = buttonState;
   // delay 3 ms and read it again
   delay (3);
   debounceFlag2 = digitalRead(buttonPin);
   // if it still reads High after 3 ms delay
   if (debounceFlag1 = debounceFlag2); {
      // increment the button counter
      // keyboard print test
      if (counter>=crankratio){
        counter = 0;
        // type out a message
        //Keyboard.print("You pressed the button ");
        //Keyboard.println(" times.");;
    debounceFlag1 = 0;
    debounceFlag2 = 0;
  // save the current button state for comparison next time:
  previousButtonState = buttonState; 



Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback


Similar projects you might like

Unlock your door with a knock
  • 15,322
  • 49

Full instructions

Open your door with a special knock using Arduino, Android Phone and 1Sheeld

DIY Relay Outlet Arduino
  • 20,624
  • 24

Full instructions

Control a wall outlet using an Arduino using this DIY solid state relay outlet.

Uber Home Automation
  • 25,297
  • 112

Work in progress

Wireless Arduino sensor nodes and awesome home automation platform called OpenHAB.  Know when your dog barks.

  • 5,159
  • 26

Work in progress

An obstacle-detection and GPS-enabled navigation wearable for the visually impaired.


4 members

Arduino to Excel using V-USB
  • 32,626
  • 32

Full instructions

Log 6 analog and 8 digital pins from Arduino Uno simultaneously in Excel.

Magic Morse on Arduino
  • 19,246
  • 23

Full instructions

Learn or sharpen your Morse Code skills with Magic Morse implemented on Arduino!

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login