Monday, 17 February 2014

Interfacing Sensors - Microphone Sound Detection Sensor

Microphone Sound Detection Sensor

The Microphone Sound Detection Sensor is a simple sensor that detects sound using a Condenser Mike. It can give either a RAW analog output or a Comparator based Digital Output. The Analog Output is the Output from a Potential Divider constructed between the Microphone and the Trimpot. The Digital Output is that of a Comparator that takes in the potential divider as one Input and a fixed resistance as the other. 



Connections

If you are using the Induino R3 Board, You can plug the sensor directly onto the Sensor Interface on the Board. Like in the Image Below.



  1. Connect '+' pin of the Sensor module to +5V on the Induino R3 / Arduino Board
  2. Connect the 'G' pin of the Sensor module to the GND pin on the Induino R3 / Arduino Board
  3. Connect the 'DO' pin of the Sensor module to Digital Pin 16 (A2) on the Induino R3 / Arduino Board
Adjusting the Sound Sensor Sensitivity

The Trimpot on the Sensor, lets you adjust the Sound Sensor Sensitivity. The LED marked L2 (below the Trimpot) indicates the digital output of the sensor. To adjust the sensitivity, Adjust the Trimpot using a Screw Driver. Clock Wise Rotation, Decreases the Sensitivity and Anti-Clock Wise Rotation Increases it. Once the sensitivity is set,  Verify by making a sound and checking if the LED L2 Turns On when you make the desired sound. 


Programming for the Microphone Sound Detection Sensor

Here's a Simple Program that toggles On / Off the LED on the 13th Pin everytime a clap is detected.


Here's the Program
/*  Induino R3 User Guide - Program 19.0 - Interfacing Microphone Sound Detection Sensor with the Induino R3 */

#define mic 16 // The Microphone Sound Detection Sensor's Digital Output Pin is Connected to Pin 16 / A2 of Induino R3

boolean state = 0;

void setup()
{
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
  
  // Setup the 13the pin LED for OUTPUT
  pinMode(13, OUTPUT);
  
  // Setup the sensor input pin
  pinMode(mic, INPUT);
  
}

void loop()
{
  if(digitalRead(mic)) // Check if the Sensor Input is HIGH
  {
   state = !state; // Toggle the State Variable
   digitalWrite(13, state); // Set the Current State to the OUTPUT LED
   delay(1000); // Wait for the INPUT to become stable
  }
}

Thats It For This Part! Enjoy... and feel free to drop us an email with questions you might have -> info@simplelabs.co.in

Visit www.simplelabs.co.in for more interesting products

2 comments:

  1. I tried the Microphone Sound Detection Sensor with above code on Arduino Duemolanove (D0 to A2, gnd to GND and + to 5V). The led is always blinking. When I printed the value of mic on COM and it is showing 16 always, and the digitalRead(mic) is 1. So that condition check is always true and LED blinks always. I tried changing the sensitivity by turning potentiometer, still it works the same away. What can be done to resolve this problem. I want to set a threshold value. The LED should blink only if the sensor value is above that threshold.

    ReplyDelete
  2. I have the same problem. I can get a stand alone powered microphone to work very well. But this board does not seem to fluctuate at all. I even bought two of them in case it was just a broken board. After finding nothing on the Internet, I am thinking the design of the board must be flawed.

    ReplyDelete