Hi all,
I am using a piezo to detect hits(knocks) as in
I tried different modifications of the arduino code, right now I use:
// these constants won't change:
const int ledPin = 13; // led connected to digital pin 13
const int knockSensor = A0; // the piezo is connected to analog pin 0
const int threshold = 10; // threshold value to decide when the detected sound is a knock or not
// these variables will change:
int sensorReading = 0; // variable to store the value read from the sensor pin
int ledState = LOW; // variable used to store the last LED status, to toggle the light
void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as as OUTPUT
Serial.begin(9600); // use the serial port
}
void loop() {
// read the sensor and store it in the variable sensorReading:
sensorReading = analogRead(knockSensor);
Serial.println(sensorReading);
delay(10); // delay to avoid overloading the serial port buffer
}
And I use a max patch to read the values with a [serial a 9600] object which is banged every ms.
Still sometimes some knocks are not recognized even though I touch the piezo as hard as before (when it was recognized).
It's not a matter of being below a threshold - it's a matter of not getting a value different from 0.
Are there any ways to make this more reliable?
Thanks a lot,
Frank