Published: August 27, 2025
A simple sound-reactive project that uses a sound sensor to detect claps or loud noises and toggles an LED on or off with each clap โ just like a clap switch lamp.
Component | Notes | Amazon Link to parts |
---|---|---|
Arduino UNO (Real & Clone) | Microcontroller board | Real - Link Clone - Link |
Sound Sensor Module | KY-038 or similar (uses digital OUT) | Link |
LED | For visual feedback | Link |
220ฮฉ Resistor | In series with LED | Link |
Breadboard + jumper wires | For easy connections | Link |
Disclaimer: The Amazon links provided above are affiliate links. This means I may earn a small commission at no extra cost to you if you make a purchase through them.
Sensor Pin | Connect to |
---|---|
VCC | 5V |
GND | GND |
OUT (D0) | D2 |
Use the digital output pin (OUT) on the sound sensor โ not the analog one (A0).
LED Leg | Connect to |
---|---|
Long leg (+) | D8 via 220ฮฉ resistor |
Short leg (โ) | GND |
Language: C++
#const int soundSensorPin = 2; // Digital OUT from sound sensor
const int ledPin = 8; // LED connected to pin 8
bool ledState = false;
bool soundDetected = false;
void setup() {
pinMode(soundSensorPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
int sensorValue = digitalRead(soundSensorPin);
// Detect sound pulse (goes LOW on sound)
if (sensorValue == LOW && !soundDetected) {
ledState = !ledState; // Toggle LED state
digitalWrite(ledPin, ledState); // Apply the new state
soundDetected = true;
delay(200); // Debounce delay
}
// Reset detection flag when sound passes
if (sensorValue == HIGH) {
soundDetected = false;
}
}
soundDetected
flag helps avoid multiple toggles from a single clapdelay(200)
helps debounce and prevent false multiple triggers