Microphone Sound Sensor

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:

  • KY-038
  • LM393

Both modules have a built-in potentiometer to adjust the sensitivity on common.

Pin description:

  • Digital signal : provide a digital signal as input
  • Analog signal : provide an analog signal as input
  • GND : To provide GND signal to module
  • VCC : To provide VCC signal to module

 

 

 

Components:

  • 1 x microphone sound sensor
  • 1 x Arduino UNO
  • 1 x LED
  • Jumper wires

 

Example of microphone sound module with Arduino:

Step 1: Connecting module with Arduino

  • Connect D0 pin of module to pin no 7 of Arduino
  • Connect GND pin of module to GND of Arduino
  • Connect VCC pin of module to 5V of 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

  • Copy and paste the code from below in Arduino IDE
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);
  }
}
  • Click on upload

 

 

 

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.