Simple Arduino Clap Switch with LED and Relay: A DIY Guide

Simple Arduino Clap Switch with LED and Relay: A DIY Guide

Welcome to the world of DIY home automation! In this tutorial, we’ll guide you through the process of creating a simple Arduino clap switch with LED and relay control. This project not only adds a fun element to your home but also introduces you to the basics of sound sensor interfacing with Arduino.

For a visual guide, our YouTube tutorial below can be watched. Follow along for a step-by-step demonstration.

Arduino Clap Switch Using Sound Sensor | Easiest Way


Imagine turning on or off your lights with just a clap! Imagine turning on or off your lights with just a clap! This Arduino clap switch project enables this possibility. Home automation has never been this simple and exciting. Let’s dive into the details of creating your very own clap-activated switch.

Components Required for Arduino Clap Switch

Arduino Uno× 1Amazon
LM393 Sound Sensor Module× 1Amazon
5V Relay Module× 1Amazon
LED and resistor kit× 1Amazon
Breadboard× 1Amazon
Jumper wires kit× 1Amazon
USB cable type A/B× 1Amazon

These components are affordable and widely available, making this project accessible to everyone.


Arduino IDE

LM393 Sound Sensor Module

The LM393 Sound Sensor is the heart of our clap switch. It detects sound intensity and sends signals to the Arduino. For protection, switching, and monitoring applications, this module can be used. Adjusting its precision for ease of use is easy. It uses a microphone that provides an amplifier, high detector, and buffers for the signal.

The sensor generates an output signal voltage when it detects sound., which is then sent to a microcontroller, which performs the required processing.
The sound detector sensor module for Arduino determines whether or not sound has crossed a predefined threshold value. A microphone detects sound, which is then fed into an LM393 op-amp. An onboard potentiometer is used to change the sound level set point. As the sound frequency reaches the threshold, an LED on the module illuminates and the output is reduced.

LM393 Sound Sensor Module Specifications

Operating  voltage3.3 V – 5 V
Sensitivity48-66 dB
Outputsone analog + one digital
Impedance2.2 kΩ
Operating temperature-40 °C to +85 °C
Frequency response50 Hz – 20 kHz
Indicator LED1 power indicator + 1 comparator output indicator
Dimensions44 x 15 x 10 mm
CostCheck price

The LM393 Sound Sensor Module is made by PRC. For more information, you can check out the LM393 Sound Sensor Module datasheet below:

5V Relay Module

A relay has three pins: NO (Normally Open) terminal, NC (Normally Closed) terminal, common pin, and coil. When the magnetic field energizes the coil, it creates connected contacts. The COM (Common) terminal, which is the moving part of a relay, connects to the NC (Normally Closed) terminal when the relay is turned off. Only when the relay is turned on, the NO (Normally Open) terminal of the relay becomes connected. The transition from NC to NO occurs when turning on the relay.

The Arduino’s instructions control the connected devices, such as the LED, via the 5V Relay Module. The 5V Relay Module controls the connected devices, such as the LED, based on the Arduino’s instructions. Properly connect the relay module to both the Arduino and the components you want to control.

5V Relay Module Specifications

Operating  voltage3.75V – 6V
Quiescent current2mA
Current when the relay is active~70mA
Relay maximum contact voltage250VAC or 30VDC
Relay maximum current10A
CostCheck price

For more information, you can check out the 5V Relay Module Datasheet below:

Arduino Clap Switch with LED Circuit Schematics

Refer to the image below for the circuit connection. Follow the steps to ensure a correct and functional setup.

Arduino Clap Switch with LED Circuit Schematics
Arduino Clap Switch with LED Circuit Schematics

The following connections are also shown in the table:

LM393 Sound Sensor Module Connections

LM393 Sound Sensor ModuleArduino
D0Digital pin 2

Resistor’s one terminal goes to LED and another terminal goes to digital pin 3.

Arduino Clap Switch with Relay Circuit Schematics

Arduino Clap Switch with Relay Circuit Schematics
Arduino Clap Switch with Relay Circuit Schematics

Connections are also shown in the table:

Relay Module Connections

5V Relay ModuleArduino
INDigital pin 2

A bulb connects with a 5V relay module’s NO pin and NC pin. 

warning signWarning
This board interfaces with a high-voltage AC supply.   Improper or incorrect use may result in serious injury or death. As a result, it is intended for people who are familiar with and knowledgeable about HIGH AC voltage.

Arduino Clap Switch Code

Now, let’s understand the code. The Arduino code provided controls the relay based on the sound intensity detected by the LM393 Sound Sensor. Adjust the threshold value by rotating the potentiometer to set the desired sound level for triggering the switch.

By clicking the button in the top right corner of the code field, you can copy the code. Copy and paste it into Arduino IDE. 

/***** *****/
/***** Arduino Clap Switch *****/
int SoundSensor=2; // LM393 Sound Sensor Digital Pin D0 connected to pin 2
int LED=3; // LED connected to pin 3
boolean LEDStatus=false;
void setup() {
 Serial.begin(9600); //initialize serial
void loop() {
 int SensorData=digitalRead(SoundSensor); 
  Serial.println(SensorData);//print the value

    else if(LEDStatus==true){

Caution Section

A crucial step in this project is adjusting the threshold value. Rotate the potentiometer to increase or decrease the threshold. A higher threshold means the clap switch responds to louder sounds. Find the right balance for your environment.

Result Section

After successful implementation, enjoy the convenience of controlling devices with a simple clap. Achieving the desired sound threshold ensures accurate and responsive operation.

Benefits of a Clap Switch

Clap switches offer convenience and energy-saving benefits. Imagine entering a dark room and illuminating it with just a clap. Additionally, they are great for individuals with mobility issues.

Customization Options

Feel free to experiment with different components and customize the project to suit your preferences. Personalizing your clap switch adds a unique touch to your home automation setup.

Troubleshooting Guide

Encounter issues? Consult our troubleshooting guide for common problems and solutions.

User Feedback

We love hearing success stories from our readers. Share your experiences and feedback with the Arduino clap switch project in the comments section.


Congratulations on creating your Arduino clap switch! This DIY project brings a touch of magic to your home and serves as a great introduction to Arduino and sound sensors. Enjoy the convenience of home automation with this simple yet effective solution.

Frequently Asked Questions (FAQs)

  1. Q: Can I use a different sound sensor model?
    • A: While it’s recommended to use the LM393 for this tutorial, you can experiment with other sound sensors with similar specifications.
  2. Q: What devices can I control with the relay?
    • A: The 5V Relay Module can control various devices such as lights, fans, or other electronic appliances.
  3. Q: How do I adjust the sensitivity of the sound sensor?
    • A: Rotate the potentiometer on the LM393 Sound Sensor to set the desired sensitivity level.
  4. Q: Is there a wireless option for the clap switch?
    • A: Advanced users can explore adding wireless capabilities using modules like Bluetooth or Wi-Fi.

Leave a Reply