/* Piezo Knock * ----------- * Turn a standard piezo buzzer into a force sensor * * Created 24 October 2006 * copyleft 2006 Tod E. Kurt THRESHOLD ) { // is it bigger than our minimum? digitalWrite(ledPin, HIGH); // tell the world t = 0; while(analogRead(piezoPin) > THRESHOLD) { t++; } // wait for it to go LOW (with a little hysteresis) if(t>100) { // cut off the low values because they're noise Serial.print("knock! "); Serial.println(t); } } }