I'm trying to detect if the sound goes above a given level of noise to trigger some relay.
I've setup an Arduino Mini Metro.
Currently, it is only powered by USB.
I've connected it as following:
Code: Select all
MAX4465 <----> Arduino
Out A0(=PIN 14)
GND GND
VCC 3V
Code: Select all
int mic = 14;
const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)
unsigned int sample;
void setup() {
pinMode(mic, INPUT);
Serial.begin(9600);
}
void loop() {
unsigned long startMillis = millis(); // Start of sample window
// collect data for 50 mS
Serial.println("------ New round -----");
while (millis() - startMillis < sampleWindow) {
sample = analogRead(mic);
Serial.println(sample);
}
delay(5000);
}
Code: Select all
17:11:13.999 -> ------ New round -----
17:11:14.030 -> 30
17:11:14.030 -> 30
17:11:14.030 -> 30
17:11:14.030 -> 30
17:11:14.030 -> 29
17:11:14.030 -> 30
17:11:14.062 -> 30
17:11:14.062 -> 30
17:11:14.062 -> 30
17:11:14.062 -> 30
17:11:14.062 -> 29
17:11:14.062 -> 29
17:11:14.062 -> 30
17:11:14.094 -> 30
17:11:14.094 -> 30
17:11:14.094 -> 30
17:11:14.094 -> 30
17:11:14.094 -> 30
17:11:14.094 -> 30
17:11:14.094 -> 30
17:11:14.094 -> 29
17:11:14.135 -> 30
17:11:14.135 -> 30
Any idea what I messed up?