Sound Sensor / Noise Meter with Electret Mic

This is a sound sensor that will make red LEDs light up when the noise level reaches a certain threshold. It could be useful for a classroom. It will respond to talking from across the room.

It was made using an electret microphone, which is cheap and surprisingly sensitive. Also, I used an opamp to amplify the microphone signal, it’s available for five dollars at this site. http://www.sparkfun.com/commerce/product_info.php?products_id=8704

There is a special circuit to make the microphone work. You can look at the first circuit drawing on this site: http://www.epanorama.net/circuits/microphone_powering.html or my drawing below.

                                                  • 5v
                                                    |
                                                    2k Resistor
                                                    |
                                                    0 - - - - - - 10 uF capacitor - - - - - 0 - - - - - - to Op-Amp “in”
                                                    | |
                                                    +mic 10 k Resistor
  • mic |
    | |
                                                                    • Ground

Then op amp “out” goes to an arduino analog pin, pin 4 with the code below.
The sensitivity of the mic can be adjusted by turning the potentiometer on the op amp with a screwdriver.

//SOUND MONITOR for the classroom 

int sensorPin = 4;    //Microphone Sensor Pin
int YellowLED = 1;    
int RedLED = 4;    
int sensorValue = 0; 

void setup() {
  pinMode(YellowLED, OUTPUT); 
 pinMode(RedLED, OUTPUT); 
Serial.begin(9600);
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);    
 Serial.println(sensorValue);
 
 /* If you feel that the sensor values on the serial monitor
 are going by too quickly for you to read, you can make it 
 so that the values only show up on the serial monitor 
 if you make a noise.  You can replace 
 Serial.println(sensorValue); 
  with: 
 if (sensorValue < 509){
   Serial.println(sensorValue);
 }
 
 */

  digitalWrite(YellowLED, HIGH);  //Yellow is always on.

  if (sensorValue<509){  //The 'silence' sensor value is 509-511
    digitalWrite(RedLED, HIGH);
    delay(2000);            // The red LEDs stay on for 2 seconds
} else {
    digitalWrite(RedLED, LOW);  
}
}