Created
June 4, 2011 20:51
-
-
Save greglinch/1008344 to your computer and use it in GitHub Desktop.
To measure the output of my desk pedals at work using an Arduino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ARDUINO INPUT INCREMNENTER | |
// To measure the output of my desk pedals at work | |
// Adapted from Example 03A from "Getting Started with Ardunio" by Massimo Banzi | |
// Greg Linch | |
// http://www.greglinch.com | |
#define BUTTON 7 // input pin where the push button is connected; this will soon be replaced with alternative method to measure output of pedals | |
int val = 0; // store the state of the input pint | |
int revolutions = 0; // store the number of revolutions of the pedals | |
int prvState = LOW; // set the previous state to off (LOW) | |
void setup() { | |
Serial.begin(9600); // open up comms from Arduino to serial monitor | |
} | |
void loop() { | |
val = digitalRead(BUTTON); | |
if (val == HIGH) { | |
if (prvState == LOW){ | |
revolutions++; // increment | |
Serial.println(revolutions); // print the incremented number | |
} | |
} | |
prvState = val; // save the current value to previous state so it knows | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment