Microphone Sound Sensor

A microphone is an acoustic to electric transducer or sensor that detects sound signals and converts them into an electrical signal. This guide shows how to use the microphone sound sensor with the Arduino. The microphone sound sensor, as the name says, detects sound. It gives a measurement of how loud a sound is. There is a wide variety of these sensors. In the figure below you can see the most common ones used with the Arduino.
The compactor ic sensor modules have a built-in potentiometer to adjust the sensitivity of the digital output pins.
High-sensitivity sound detection module with 2 outputs.
AO = Analog output, real-time output voltage signal of the microphone.
DO = The digital output depends on the sound intensity and the threshold that has been set.

Ao Any Analog pin of Arduino
Do Any digital pin of Arduino
GND Ground of Arduino Board
Vcc 5V DC

1. Voltage……………..3.3-5 VDC
2. Outputs……………..one analogue + one digital output
3. Fixation…………….1 x mounting screw hole (3 mm)
4. 2 indicator LEDs……..1 power indicator + 1 comparator output indicator
5. Frequency response……50 Hz – 20 KHz
6. Impedance …………..2.2 kΩ
7. Sensitivity …………48-66 dB
8. Operating temperature..-40 °C to +85 °C
9. Dimensions ………….44 x 15 x 10 mm
10. Weight………………4 g
The following are the list of applications of microphones:
1. Hearing aids
2. Telephones
3. Tape recorders and karaoke
4. Live and recorded audio engineering
5. Radio and television broadcasting
6. Speech recognition technology.
In this example, a microphone sensor will detect the sound intensity of your surroundings and will light up and LED if the sound intensity is above a certain threshold.
You can modify this project by adding more LEDs. You can also adjust your sensor sensitivity so that the LEDs are turned on or off accordingly to the beat of a music.
Copy and Paste the code or download full arduino code at bottom of the post.
//Circuito.io is an automatic generator of schematics and code for off the shelf hardware combinations.
//Copyright (C) 2016 Roboplan Technologies Ltd.
// Include Libraries
#include “Arduino.h”
#include “LED.h”
#include “Switchable.h”
#include “Mic.h”
// Pin Definitions
#define LEDG_PIN_VIN 5
#define MIC5V_PIN_SIG A3
// Global variables and defines
// object initialization
Mic mic5v(MIC5V_PIN_SIG);
// define vars for testing menu
const int timeout = 10000; //define timeout of 10 sec
char menuOption = 0;
long time0;
// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity.
void setup()
// Setup Serial which is useful for debugging
// Use the Serial Monitor to view printed messages
while (!Serial) ; // wait for serial port to connect. Needed for native USB
menuOption = menu();
// Main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop.
void loop()
if(menuOption == ‘1’)
// LED – Basic Green 5mm – Test Code
// The LED will turn on and fade till it is off
for(int i=255 ; i> 0 ; i -= 5)
ledG.dim(i); // 1. Dim Led
delay(15); // 2. waits 5 milliseconds (0.5 sec). Change the value in the brackets (500) for a longer or shorter delay in milliseconds.
ledG.off(); // 3. turns off
else if(menuOption == ‘2’) {
// Electret Microphone Breakout – Test Code
int mic5vVal = mic5v.read();
Serial.print(F(“Val: “)); Serial.println(mic5vVal);
if (millis() – time0 > timeout)
menuOption = menu();
// Menu function for selecting the components to be tested
// Follow serial monitor for instrcutions
char menu()
Serial.println(F(“\nWhich component would you like to test?”));
Serial.println(F(“(1) LED – Basic Green 5mm”));
Serial.println(F(“(2) Electret Microphone Breakout”));
Serial.println(F(“(menu) send anything else or press on board reset button\n”));
while (!Serial.available());
// Read data from serial monitor if received
while (Serial.available())
char c = Serial.read();
if (isAlphaNumeric(c))
if(c == ‘1’)
Serial.println(F(“Now Testing LED – Basic Green 5mm”));
else if(c == ‘2’)
Serial.println(F(“Now Testing Electret Microphone Breakout”));
Serial.println(F(“illegal input!”));
return 0;
time0 = millis();
return c;
Download Full Arduino IDE code Here microphone_sensor. After downloaded extract then double click Arduino code. Compile and upload to Arduino board and test the code.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.