Skip to content

Instantly share code, notes, and snippets.

@jordanorelli
Created February 16, 2014 04:01
Show Gist options
  • Save jordanorelli/9029038 to your computer and use it in GitHub Desktop.
Save jordanorelli/9029038 to your computer and use it in GitHub Desktop.
int val;
int scratch_min = 12;
int scratch_max = 128;
int scratches = 0;
boolean scratched = false;
void setup() {
Serial.begin(9600);
}
void loop() {
val = analogRead(A0);
if (millis() % 100 > 90) {
if (scratches > 2) {
scratched = true;
Serial.println("scratched");
} else {
scratched = false;
Serial.println("not scratched");
}
scratches -= 1;
} else {
if (scratches < 5 && val >= scratch_min && val <= scratch_max) {
scratches++;
}
}
delay(10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment