Hello, have you ever wanted to control an LED just by making a noise, like clapping your hands? Well, you’re in the right place! In this guide, I’ll show you how to use a sound sensor with an Arduino Uno to make that happen in a super simple way. Don’t worry if you’re new to this – I’ll walk you through everything step by step.
Materials Required
Part | Quantity |
---|---|
Arduino Uno with USB A to B cable | 1 |
Computer with Arduino IDE | 1 |
KY-038 sound sensor module | 1 |
LED | 1 |
Jumper wires (male-to-female) | 3 |
Flat head screwdriver | 1 |
Arduino IDE (software) | 1 |
Connections

First, take 3 jumpers and place them on the headers of the sensor module labeled Ground (G), Positive (with a plus sign), and Digital Output (DO). Then take the other end of the jumper wires you have put and join the positive of the sound sensor module to the 5V of the Arduino the ground to any of the GND of the Arduino, and the Digital Output to pin 2 of the Arduino.
Then take the LED. The positive lead is the longer one, and the ground is the shorter lead. Join the ground to GND and the positive lead to pin 13 of the Arduino. So now the connections are done.
Programming the Arduino

Next, join the Arduino to the computer, install the Arduino IDE and the code I have provided, open the file, and select the COM port to the one where the Arduino is plugged. Next to “boards,” select Arduino Uno, then click Upload. The programming is done.
int sensor = 2; // Connected to digital output of KY-038 sound sensor module
int led = 13; // Connected to positive of led
boolean is_on = false; // To determine/track if led is on or off
void setup() {
pinMode(sensor, INPUT); // Setting the pin to input for reading data
pinMode(led, OUTPUT); // Setting the pin to output for turning the led on/off
}
void loop() {
int data = digitalRead(sensor); // Reading data from sensor and storing in variable
if (data == 1) { // 1 is sent from sensor when loud noise is detected
if (is_on == true) { // If led is on then turn it off
digitalWrite(led, LOW);
is_on = false;
} else { // If led is off then turn it on
digitalWrite(led, HIGH);
is_on = true;
}
}
Adjusting the Sensitivity of the Sound Sensor

Now you need to take the screwdriver and rotate the potentiometer to adjust the sensitivity of the sound sensor. First, rotate it clockwise until the built-in LED glows without producing any noise. Then rotate it slowly in the counterclockwise direction until the built-in LED is switched off. Now, if you clap loudly by producing a loud noise, the LED joined to the Arduino will glow. If you clap again then it will switch off.
If it’s not functioning properly or you are having difficulty turning the LED on by making a loud noise, then you may need to further adjust the sensitivity and test it by making loud noises.
Complete
So now you can turn an LED on or off by clapping. Thank you for reading! If this Instructable helped you, please favorite it, comment, and share. Also, please check out my YouTube channel where I post videos on electronics and robotics. Bye!
