So all i am trying to do is loclaise a sound source. I have tow (Sound inpu module) from freetronics, i am using the SPL input,
So far, the code i wrote compares which microphone has a higher SPL and gives me a direction, but i can make this more precise if i can cimpute the time difference betwen microphone one and two
float splSensor = A0; // the SPL output is connected to analog pin 0
float splSensor1 = A1;
void setup() {
Serial.begin(57600);
}
void loop() {
if (analogRead(splSensor1) > analogRead(splSensor))
Serial.println("L");
if (analogRead(splSensor) > analogRead(splSensor1))
Serial.println("R");
if (analogRead(splSensor1) == analogRead(splSensor))
Serial.println("C");
delay(200); // delay to avoid overloading the serial port buffer
}
It is difficult to do what you want with the Arduino alone, because it has only one ADC.
First, you have to decide what constitutes the signal of interest (a given sound pressure level or waveform peak, etc.). Then you measure the input on two channels, marking the time on each channel where that signal is observed. Since the signals on the two channels won't be identical, that is not completely straightforward.
It takes a significant amount of time for the Arduino to switch channels and make each individual measurement, which introduces additional uncertainty. Printing while making measurements makes this even worse.
So i can specy a certain cound level to look for and then compare the time difference. i am happy it will not be super accurate however, all i want to do is allocate a time stamp for when hte first one received a signal, then the other and compare the two, is this difficult?
Yes, it's incredibly difficult, unless you restrict the task to very simple requirements. For example, only detect a single loud impulse (bang, snap, crack, etc.). Condition the signal with some kind of analog filter and peak detector prior to the Arduino input. For anything better you would need a DSP. I think you will be disappointed with the results of anything basic that you can do.
There is a long list of technical difficulties involved. Unless you are a human being, a rabbit or a porpoise.
A faster ADC will not help you if you want to localize something like a cat meowing. Not with the processing power of an Arduino. Because the signal has to processed, even if in a very rudimentary way.