The Microphone Sound Sensor



The microphone sound sensor, as the name says, detects sound. It gives a measurement of how loud a sound is.

There are a wide variety of these sensors.  In the figure below you can see the most common used with the Arduino.


Guide for the microphone sound sensor


At the leftmost side, you can see the KY-038 and at the right the LM393 microphone sound sensor.

Both sensor modules have a built-in potentiometer to adjust the sensitivity of the digital output pin.



Wiring your sensor to the Arduino is pretty straightforward:



Wiring to Arduino


Analog pins


Digital pins






If you’re using the LM393 module, you should connect the OUT pin to an Arduino digital pin.



Example: Sound Sensitive Lights


In this example, a microphone sensor will detect the sound intensity of your surroundings and will light up an LED if the sound intensity is above a certain threshold.



Parts required


For this example you’ll need the following components:

  • 1x Microphone sound sensor
  • Arduino UNO – read Best Arduino Starter Kits
  • 1x Breadboard
  • 1x LED
  • 1x 220 Ohm resistor
  • Jumper wires





Assemble all the parts by following the schematics below:


Guide for the microphone sound scensor






Upload the following code to your Arduino board.



 * Rui Santos 

 * Complete Project Details


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);



view rawProjects/Arduino_microphone_sensor.ino




After uploading the code, you can clap next to the sensor. If the LED is not lighting up, you need to change the sensor sensitivity by rotating the potentiometer.


Demo gif


You can also adjust the sensitivity so that the LED follows the beat of a certain music.

Add more LEDs for a more spectacular effect!



Les commentaires sont clôturés