How to Make a Clap Switch With Arduino

Introduction: How to Make a Clap Switch With Arduino

I thought this would be a cool project to have in my room to add a bit of style and functionality so I wouldn't have to flip on a switch every time I wanted some light. I got inspiration to make this because i only have one light in my room and it only lights up half my room well.

Supplies

- Arduino Uno

- Computer to upload code to the Arduino

- 12v relay

- LED Light strip(s)

- Sound Sensor Detection Module

- Printer cable to power the Arduino

- Cardboard to make a box for it (not necessary)

Step 1: Wiring Up Your Components

I have provided a wiring explanation in my video above, but I will go through each cable you need to connect here.

Relay Wiring:

- GND to GND on Arduino

- SIG to Pin 10 on Arduino

- VCC to 5v on Arduino

Sound Sensor Module Wiring:

- GND to GND on Arduino

- OUT to Pin 2 on Arduino

- +5v to 5v on Arduino

Step 2: Wiring the Relay With the LED Strip

The relay is the actual item switching on and off the lights in the build. That being said, you will have to cut the original power cable powering the LED strip up so that it works with the relay. Don't be scared because it isn't that hard, I'll walk you through it.

Step 1: Cut the cable in half with some scissors.

Step 2: Use wire cutters to get rid of about an inch of the black insulation on the outside of the wiring.

Step 3: Now you will see two smaller wires inside the outer black insulation, a red one, and a black one.

Step 4: Do the same for each of the smaller cables.

Step 5: Put the red wire from each side of the cable into either the left slot or the right slot in the relay, either works.

Step 6: Take each of the black wires from each side of the cable, twist them together, and wrap them in electrical tape. And that's it!

Step 3: Code for the Arduino

First thing you have to do is to download Arduino IDE. Next, plug the Arduino via a printer cable (USB AB cable). Then Copy and paste this code in and upload it to the Arduino.

void loop() {

int soundSensor=2;

int LED=4;

boolean LEDStatus=false;

void setup() {

pinMode(soundSensor,INPUT);

pinMode(LED,OUTPUT);

}

void loop()

int SensorData=digitalRead(soundSensor);

if(SensorData==1){

if(LEDStatus==false){

LEDStatus=true;

digitalWrite(LED,HIGH);

}

else{

LEDStatus=false;

digitalWrite(LED,LOW);

}

}

}

}

Step 4: Admire Your Work

You now have a fully functional clap switch that you can put just about anywhere, good job!

Be the First to Share

    Recommendations

    • Space Contest

      Space Contest
    • Robots Contest

      Robots Contest
    • Rocks, Gems, and Stones Speed Challenge

      Rocks, Gems, and Stones Speed Challenge

    2 Comments

    0
    Penolopy Bulnick
    Penolopy Bulnick

    1 year ago

    This is neat! Thanks for sharing the video :)