Skip to content

Instantly share code, notes, and snippets.

@greglinch
Created June 4, 2011 20:51
Show Gist options
  • Save greglinch/1008344 to your computer and use it in GitHub Desktop.
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
// 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