Clap switch – Turn on and off light / Fan by clapping using Arduino

Here I am going to describe how you can make a very interesting Arduino project.

It is a clap switch. You can turn on & off your Electrical appliances like light, Fan remotely just by clapping.

When you clap for the first time the Relay module turns on the electrical appliances & next clap turns off.

We can make this project using 4 transistors which is a transistor clap switch circuit or using IC 4017 but we will make it more efficient & less complicated. We are going to use an Arduino Uno board.

Arduino clap switch
Arduino clap switch

Advantages of Arduino based clap switch

  • It is easy for making 
  • It is error-free & better than an analog circuit

If you want to make it for regular use in your home then I will recommend, please use Arduino nano and make a circuit on a perf board.

You need to make

Arduino UNO
Arduino UNO
  1. Sound sensor module
  2. Single-channel relay module
  3. Jumper wire
  4. Small breadboard
  5. 9v battery & battery connector
  6. Ac wire, plug & ac bulb
  7. Arduino UNO


Connect sound sensor module(+)pin to Arduino 5V

Connect sound sensor module (-) pin to Arduino GND

Connect sound sensor module signal pin to Arduino D6

Connect relay module (+) to Arduino 5v & GND to GND

Connect relay module signal pin to Arduino D7 pin.

Circuit Diagram

Clap switch circuit diagram
Clap switch circuit diagram

AC connection

Disclaimer for Ac Use

If you don’t know about Ac electrical connection please don’t try & take help from an experienced person.

Don’t touch the circuit when the AC line is connected.

Ac line is connected to the relay module. This relay module is working like a switch. Please follow the circuit diagram.

Working of the Arduino clap switch

Clap switch working
Clap switch working

Its working principle is very easy. when the sound sensor detects a louder sound, the signal pin is getting high for a few seconds.

The signal pin is connected to Arduino D6. It is an input pin. 

So when the D6 is getting high then the D7 output (which is connected to the relay module signal pin) becomes high.


When the D7 is at the high position then if the sound sensor detects any louder sound then the output pin D7 becomes Low.

Video guide

Arduino Code for clap switch

Uploading code to Arduino Ide

Upload the Arduino code using Arduino IDE

int micPin = A0;          // pin that the mic is attached to
int gndPin = A1;
int powerPin = A2;
int micValue1 = 0;  
int micValue2 = 0; // the Microphone value
int led1 = 13;
boolean lightOn = false;

void setup() {
  pinMode(led1, OUTPUT);
  pinMode(powerPin, OUTPUT);
  pinMode(gndPin, OUTPUT);
  pinMode(micPin, INPUT);
  Serial.begin(9600);  //for test the input value initialize serial

void loop() {
  micValue1 = analogRead(micPin);  // read pin value
  micValue2 = analogRead(micPin);
  if (micValue1-micValue2 > 2||micValue2-micValue1 > 2){
  lightOn = !lightOn;
  digitalWrite(led1, lightOn);

Leave a Reply

Your email address will not be published. Required fields are marked *