Introduction
This experiment involves using a sound detection sensor to measure sound levels in the environment. It can be used to create sound-activated devices.
Components Needed
- Sound Detection Sensor
- Arduino (e.g., Uno, Nano)
- Jumper wires
- Breadboard
Circuit Setup
- Connect the VCC pin of the sound sensor to the 5V pin of the Arduino.
- Connect the GND pin of the sensor to the GND pin of the Arduino.
- Connect the OUT pin of the sensor to pin D2 on the Arduino.
Ensure all connections are secure and that the sensor is positioned in an area with sound.
Code for Sound Detection Sensor
Upload the following code to your Arduino to detect sound:
const int soundPin = 2; // Pin connected to the sound sensor
void setup() {
pinMode(soundPin, INPUT); // Set the sound pin as input
Serial.begin(9600); // Start serial communication
}
void loop() {
if (digitalRead(soundPin) == HIGH) {
Serial.println("Sound Detected!");
} else {
Serial.println("No Sound");
}
delay(100); // Delay for stability
}
Explanation
The sound detection sensor detects sound through a microphone and outputs a high or low signal to the Arduino. The Arduino reads the signal and prints "Sound Detected!" to the Serial Monitor when a sound is heard.
Troubleshooting
- If no sound is detected, ensure the sensor is in an appropriate environment with sufficient sound levels.
- If the sensor is too sensitive, adjust the sensitivity using the onboard potentiometer.