Interfacing of Sound sensor with Arduino Uno.
What is a Sound Sensor?
The Sound Sensor Module provides an easy way to detect sound and is generally used for detecting sound Intensity. This Module can be used Security, Switch and Monitoring applications. Its accuracy can be easily Adjusted for the convenience of the usage.
It uses a Microphone which supplies the input to an amplifier, peak detector and buffer. When a Sensor detects
a sound , it processes an output signal voltage which is sent to microprocessor , and performs further processing.
Material Required:
Material Quantity
Arduino Uno 1
Sound Sensor 1
Jumper cables 5
Resistor 1(1k ohm)
Pinout Diagram:
Circuit Diagram:
Parameter Value
VCC 5 V DC from your Arduino
Ground GND from your Arduino
Out Connect to Digital Input Pin
Tested Programming Code:
//Arduino Sound Detection Sensor Module
int soundDetectedPin = 10; // Use Pin 10 as our Input
int soundDetectedVal = HIGH; // This is where we record our Sound Measurement
boolean bAlarm = false;
unsigned long lastSoundDetectTime; // Record the time that we measured a sound
int soundAlarmTime = 500; // Number of milli seconds to keep the sound alarm high
void setup ()
{
Serial.begin(9600);
pinMode (soundDetectedPin, INPUT) ; // input from the Sound Detection Module
}
void loop ()
{
soundDetectedVal = digitalRead (soundDetectedPin) ; // read the sound alarm time
if (soundDetectedVal == LOW) // If we hear a sound
{
lastSoundDetectTime = millis(); // record the time of the sound alarm
// The following is so you don't scroll on the output screen if (!bAlarm){
Serial.println("LOUD, LOUD"); bAlarm = true;
}
}
else
{
if( (millis()-lastSoundDetectTime) > soundAlarmTime && bAlarm){ Serial.println("quiet");
bAlarm = false;
}
}
}
Precautions:
1. Double check the connections before powering on the circuit.
2. Don’t use loose jumper cables.
3. Check whether proper board is selected from Arduino IDE.
4. Ensure proper placement of Sound Sensor for correctworking.
5. Don’t lose hope if Sound Sensor does not run properly for the first time, try again.
Conclusion:
Once your sketch is running, you will want to open your serial monitor. Make some loud noises and and view the results