const int led = 11; // LED connected to pin 11
const int sound = 7; // Sound sensor output connected to pin 7
int soundVal = 0; // Variable to store sensor reading
void setup() {
pinMode(led, OUTPUT); // Set LED pin as OUTPUT
pinMode(sound, INPUT); // Set sound sensor pin as INPUT
}
void loop() {
soundVal = digitalRead(sound); // Read sound sensor value
if (soundVal == LOW) { // Check if sound is detected (LOW signal)
digitalWrite(led, HIGH); // Turn ON LED
} else {
digitalWrite(led, LOW); // Turn OFF LED
}
}
Instruction Details
Wiring: Connect sound detector VCC to 5V, GND to GND, OUT to Digital Pin 7. Connect LED anode to Digital Pin 11 via 220Ω, cathode to GND.
Library: Not required (built-in).
Upload Code: Tools → Board → Arduino Uno. Tools → Port → select your COM port. Click Upload button.
View Output: LED turns ON when sound detected. Clap or make noise to test. Adjust onboard potentiometer for sensitivity.
How to Use
Connect the required components as per the Pin Configuration above
Open Arduino IDE and create a new sketch
Copy and paste the code above
Select your Arduino board and COM port from Tools menu
Click the Upload button to upload the code to your Arduino
Open Serial Monitor (if applicable) to see the output