Im working on a project where I need the microphone module to send analog values for the sound "levels" to my computer. For some reason the module does not seem to be sending any values at all/not affecting the values I see in the serial monitor. What I do see in the serial monitor is a consistent 517. Does anyone know why this is? I'll provide any additional information if needed.
int micPin = A2;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int micRead = analogRead(micPin);
Serial.println(micRead, DEC);
delay(1000);
}
Analog measure scale default is VCC, 5V on an Uno.
The Uno chip also provides an internal 1.1V reference that lets the ADC 0 to 1023 cover that 1.1V range instead of 5V.
Try this code, which samples the pin as rapidly as possible (given the default settings) and reports the high and low values every so often. Values around 512 (or other midpoint) represent silence, or possibly, a nonfunctional microphone.
int micPin = A2;
int audio_min = 10000;
int audio_max = 0;
int count = 0;
void setup() {
Serial.begin(115200);
}
void loop() {
int value = analogRead(micPin);
if (value > audio_max) audio_max = value;
if (value < audio_min) audio_min = value;
count++;
if (count >= 5000) {
Serial.print("min ");
Serial.println(audio_min);
Serial.print("max ");
Serial.println(audio_max);
audio_min = 10000; //reset min, max and counter
audio_max = 0;
count = 0;
}
}
Those modules typically have two outputs, analog (A) and digital (D). The sensitivity of the digital output D can be adjusted by turning the screw on the rectangular blue box, which is a potentiometer.
You should connect to the analog output to use the analog input.