Microphone sound sensor is a sound detector module to detect sounds of the outer environment. It gives an approximate value of how high or low the sound is.
Types of microphone sensor in market:
Both modules have a built-in potentiometer to adjust the sensitivity on common.
Pin description:
Components:
Example of microphone sound module with Arduino:
Step 1: Connecting module with Arduino
Note- If you are using LM393 you must connect OUT pin to an analog or digital pin of Arduino.
Step 2: Uploading the code
int ledPin=13;
int sensorPin=7;
boolean val =0;
void setup(){
pinMode(ledPin, OUTPUT);
pinMode(sensorPin, INPUT);
Serial.begin (9600);
}
void loop (){
val =digitalRead(sensorPin);
Serial.println (val);
// when the sensor detects a signal above the threshold value, LED flashes
if (val==HIGH) {
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
}
Conclusion:
Microphone sensor will detect the sound of your surroundings and turn on the led if the sound intensity is above a certain threshold.
After uploading the code, you can make a sound next to the sensor (i.e. Clap).
Change the sensor sensitivity for better control over LED.
(Incase LED is not lightning up try changing the sensitivity of sensor)
You can adjust the sensitivity to make LED follow the beat of a certain music.