Index
Introduction
The sound sensor module is an excellent way to detect sound levels and can be used in various projects, such as sound-activated lights or alarms. It typically includes a microphone and an analog output that corresponds to the sound level detected. This guide will show you how to set up a sound sensor with Arduino to read sound levels.
Required Components
- Arduino Board (e.g., Arduino Uno)
- Sound Sensor
- LED
- Jumper Wires
- Breadboard (optional)
Pinout
Circuit Diagram / Wiring
- SOUND SENSOR
- SOUND SENSOR VCC → 5V (Arduino)
- SOUND SENSOR GND → GND (Arduino)
- SOUND SENSOR AO (Analog Output) → Pin A0 (Arduino)
- LED
- Connect the longer leg (anode) of the LED to digital pin 13 through a 220-ohm resistor.
- Connect the shorter leg (cathode) to the GND pin.
Programming With Arduino
- Copy and paste the provided code into a new sketch in the Arduino IDE:
const int LED = 13;
const int Sensor = A0;
int level;
const int threshold = 640;
void setup()
{
pinMode (LED, OUTPUT);
Serial.begin(9600);
}
void loop() {
level = analogRead(Sensor);
if (level > threshold)
{
digitalWrite (LED, HIGH);
delay (1000);
digitalWrite (LED, LOW);
}
else
{
digitalWrite(LED, LOW);
}
}
Explanation
- The sensor reads analog values from pin
A0
. - A threshold level of 640 is set to detect high values (this can be adjusted).
- The LED on pin
13
turns on for 1 second when the sensor reading exceeds the threshold. - A potentiometer can be used to adjust the threshold sensitivity to detect sound levels more or less easily.
Testing and Troubleshooting
- Check Connections: Ensure that the wiring is correct, and the sensor is receiving power.
- Adjust Sensitivity: If available, use the onboard potentiometer to adjust the sensitivity of the sound sensor to suit your project needs.