Skip to content

Instantly share code, notes, and snippets.

@Arachnid
Created December 4, 2014 15:55
Show Gist options
  • Save Arachnid/9acde4424fbecf744708 to your computer and use it in GitHub Desktop.
Save Arachnid/9acde4424fbecf744708 to your computer and use it in GitHub Desktop.
#define PIN 3
void setup() {
Serial.begin(115200);
}
void loop() {
long last = 0;
boolean last_value = -1;
while(1) {
boolean value = digitalRead(PIN);
if(value != last_value) {
long now = micros();
Serial.print(value);
Serial.print(" ");
Serial.println(now - last);
last = now;
last_value = value;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment