Introduction
This experiment demonstrates how to control a device, like an LED, using a clap sound detected by a microphone sensor.

Components Needed
- Microphone Sensor
- LED
- Arduino (e.g., Uno, Nano)
- 220-ohm Resistor
- Jumper wires
Circuit Setup
- Connect the microphone sensor to the 5V pin and GND on the Arduino.
- Connect the output pin of the microphone sensor to a digital input pin (e.g., D2) on the Arduino.
- Connect the anode of the LED to pin 13 and the cathode to GND through a 220-ohm resistor.
Ensure the microphone sensor is placed where it can detect the sound of a clap.

Code for Clap Switch Circuit
Upload the following code to your Arduino to toggle the LED when a clap is detected:
const int micPin = 2; // Pin connected to the microphone sensor
const int ledPin = 13; // Pin connected to the LED
int micValue = 0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(micPin, INPUT);
}
void loop() {
micValue = digitalRead(micPin);
if (micValue == HIGH) {
digitalWrite(ledPin, HIGH); // Turn LED on
} else {
digitalWrite(ledPin, LOW); // Turn LED off
}
}
Explanation
The microphone sensor detects sound. When a loud sound, like a clap, is detected, the LED turns on. Otherwise, it stays off.
Troubleshooting
- If the LED does not respond, check the wiring and ensure the microphone sensor is connected to the correct pin.
- If the sensor is too sensitive or not sensitive enough, adjust its sensitivity settings (if available).