/* Piezo Knock * ----------- * Превратите стандартную пьезо-пищалку в датчик силы * * 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!=0) { Serial.print("knock! "); Serial.println(t); analogWrite(motorPin,100); delay(1000); analogWrite(motorPin,0); } } }