Description:
- Size: About 32mm17mm15mm (length * width * height)
- Main Chip: LM393, Electret condenser microphone
- Working Voltage: DC 4-6V
-
Signal Output Indication:
- Single channel signal output
- The output effective signal is low level
- When there is sound, the output is low, and the signal lights up
-
Applications:
- Can be used for acoustic control light
- Works with a photosensitive sensor for sound and light alarm
- Maximum Induction Distance: 0.5 meters
- Documentation:Â sound detection module datasheet
Â
Workshop:
Pinout:
The sound sensor only has three pins:
Â
VCCÂ supplies power to the sensor. It is recommended that the sensor be powered from 3.3V to 5V.
GNDÂ is the ground pin.
OUTÂ pin outputs HIGH under quiet conditions and LOW when sound is detected. You can connect it to any digital pin on an Arduino or to a 5V relay directly.
Wiring Diagram:
Connections are fairly simple. Start by connecting the module’s VCC pin to the Arduino’s 5V pin and the GND pin to ground.
Finally, connect the OUT pin to Arduino digital pin #8. That’s it!
The wiring is shown in the image below.
Setting the Threshold:
The module has a built-in potentiometer for setting the sound level threshold above which the module outputs LOW and the status LED lights up.
Now, to set the threshold, click your finger close to the microphone and adjust the potentiometer until the module’s Status LED blinks in response to your clicks.
That’s all there is to it; your module is now ready to use.
Sample Code:
The following simple example detects claps or snaps and displays a message on the serial monitor.
Â
#define sensorPin 8
// Variable to store the time when last event happened
unsigned long lastEvent = 0;
void setup() {
pinMode(sensorPin, INPUT); // Set sensor pin as an INPUT
Serial.begin(9600);
}
void loop() {
// Read Sound sensor
int sensorData = digitalRead(sensorPin);
// If pin goes LOW, sound is detected
if (sensorData == LOW) {
// If 25ms have passed since last LOW state, it means that
// the clap is detected and not due to any spurious sounds
if (millis() - lastEvent > 25) {
Serial.println("Clap detected!");
}
// Remember when last event happened
lastEvent = millis();
}
}
If everything is working properly, you should see the following output on the serial monitor when the clap is detected.