Hi, I wanna make a knock detector using a microphone with an op-amp circuit (from the google)(lm358)
And a simple code that act whenever the analog read of the pin is greater then value or lower then it, witch totally works on <50 delay but when I use 100 delay it doesn't work anymore.
My question is how I can improve the circuit to make the signal longer (like the pir module)?
Circuit:
I also have tl062cp witch works with this circuit too
But I don't know if is better to use it
Why make a knock detector with a microphone.
A knock detector (direct surface contact) with a 1" piezo disk will likely work much better.
Can post a sketch that is more reliable and more sensitive than the commonly used KnockSensor sketch.
The diagram posted is a sound detector.
Supply the LM358 from Arduino's 5volt pin. Use the "dotted line" output, not the cap output.
Read continuously with an analogue input, and subtract the ~512 offset from your readings.
A threshold could be set with an "if" statement.
Post the code you have so far.
Leo..
Hi,
delay of 100mS, STOPS the code for 100mS, nothing happens, not even an AtoD conversion.
You need to look at an Example called "Blink without Delay' to se how to do timing without the delay command.
TomGeorge:
Hi,
delay of 100mS, STOPS the code for 100mS, nothing happens, not even an AtoD conversion.
You need to look at an Example called "Blink without Delay' to se how to do timing without the delay command.
Tom...
So, the answer to my question is that
there is no way i can improve the circuit so the signal can become longer, maybe to become 100 ms instead of just 3 ms
The thing with the code is that in the loop is has so many task and each task cost the arduino some time to complete it so the delay get longer so the knock is not detected anymore
Hi,
You could get the output of your circuit to trigger a monostable.
This would give a constant width pulse out no matter how short the input pulse.
The sensitivity would have to be set in your amplifier as the output would be a 5V pulse each time a knock was detected.
TomGeorge:
Hi,
You could get the output of your circuit to trigger a monostable.
This would give a constant width pulse out no matter how short the input pulse.
The sensitivity would have to be set in your amplifier as the output would be a 5V pulse each time a knock was detected.
Look up , pulse extenders also monostable timer
Tom..
I used Tl062cp as the omp amp with the circuit i linked in the first post
555 timer with a 330uF cap and a variable res
and i use an object to keep the microphone on the table so it will be more sensible
I wrote this sketch for another project. Very sensitive if you position the piezo in right place.
Use the piezo and resistor mentioned at the start of the sketch.
It has an alarm with threshold. Remove if you like.
Leo..
// knock sensor/alarm
// Piezo, with 1Megohm load resistor across, connected to A0 and ground
// optional 5volt buzzer on pin 13
int threshold = 100; // alarm threshold from 1 (very sensitive) to 1022 <<<<<<<<
int alarmDuration = 100; // alarm duration in milliseconds <<<<<<<<
const byte piezoPin = A0;
int rawValue; // raw A/D readings
int piezoValue; // peak value
const byte onboardLED = 13; // onboard LED and/or buzzer
void setup() {
analogReference(INTERNAL); // remove this line if too sensitive
Serial.begin(115200); // serial monitor for raw piezo output
pinMode (onboardLED, OUTPUT);
}
void loop() {
// reset
piezoValue = 0;
// read
for (int x = 0; x < 250; x++) { // multiple A/D readings
rawValue = analogRead(piezoPin);
if (rawValue > piezoValue) {
piezoValue = rawValue; // store peaks
}
}
// print
if (piezoValue > 0) {
Serial.print(F("Piezo value is "));
Serial.println(piezoValue);
}
// action
if (piezoValue > threshold) {
Serial.print(F("Knock was over the threshold of "));
Serial.println(threshold);
digitalWrite (onboardLED, HIGH);
delay(alarmDuration);
digitalWrite (onboardLED, LOW);
}
}