Sound Test Using MAX9812 microphone amplifier module:
I bought the microphone amplifier module from Amazon and connected as shown in the image. it has 3 pins.
- GND
- VCC, which can be either 3.3V or 5V (a 3.3V stabilizer is included)
- OUT, which should be connected directly to an arduino analog input pin
GND pin is connected to Ground of Arduino Uno
VCC is connected to 5V of Arduino Uno board.
Out data pin is connected to A0 port.
Arduino Sketch:
//size of the window
const int inputWindow = 100;
// placeholder for a single measurement
unsigned int inputSample;
void setup() {
// initializing the serial communication
Serial.begin(9600);
}
void loop() {
// two variables for minimum and maximum values in window
unsigned int inputMax = 0;
unsigned int inputMin = 1024;
// loop for the window
for (unsigned int i = 0; i < inputWindow; i++) {
// read in a single value
inputSample = analogRead(A0);
// get the minimum and maximum value
inputMin = min(inputMin, inputSample);
inputMax = max(inputMax, inputSample);
}
// send the values on serial
Serial.print(“Min: “);
Serial.print(inputMin);
Serial.print(” Max: “);
Serial.print(inputMax);
Serial.print(” Diff: “);
Serial.print(inputMax – inputMin);
Serial.println();
}
Output of the sketch in the serial windows looks like this: