Introduction: Turn ON and OFF Any Ac Devices With Claps

Like to being a god who can turn on and off any devices at your couch. ya I know you want to be but it comes at a cost of buying home assistants. There is an old saying that "OLD IS GOLD". Before the invention of AI we used clap circuits to turn on and off bulbs and other appliances. I am going to do the same with modern technology. LETS GET STARTED.

Step 1: WATCH MY VIDEO

Watch my video, because reading is much harder than watching videos. I wrote this Instructables because I gave mode details about the steps and the circuit diagrams.

Step 2: Components Required

1 - kY038 sound sensor module

1 - 5 volt relay module

1 - Arduino Nano

1 - 10 k potentiometer and its knob

1 - AC SOCKET (max rating of relay should be the max current rating of ac socket)

1 - Mains Power cord (make sure that wire can handle the max current of relay)

1 - Fuse holder

1 - Glass fuse(current rating of glass fuse should be the current rating of relay module)

Step 3: Connection Between Arduino Nano and Sound Sensor

Connection

DO PIN TO D7 PIN OF ARDUINO

(+) TO 5VOLTS

(G)TO GND PIN OF ARDUINO

Step 4: Connection Between Arduino Nano and Relay Module

IN PIN TO DIGITAL PIN 5 OF THE ARDUINO

VCC TO 5 VOLTS

GND TO THE GROUND PIN OF THE ARDUINO

Step 5: DOWNLOAD THE CODE

DOWNLOAD THE CODE FROM BELOW

EXPLANATION OF CODE

Firstly, we declare the sound sensor pin as 7 and relay pin as 5.

Then, The LAST EVENT variable stores the previous time since the clap was detected.

The BOOLEAN Relay State variable stores the state of the relay whether it is ON or OFF.

Then in the set-up section,

we declare the relay pin as output and the sound sensor pin as an input.

Then in the loop section,

we read the data from the sound sensor.

If the pin 7 stays low for 25 milliseconds then the clap is detected.

We use 25 millisecond here because a normal clap is only 22 milliseconds.

Then the relay turns ON or OFF depending on the last state of the relay whether the relay is ON or OFF.

If the relay is ON and we clap then the relay turns OFF and the other way around.

Upload the code to the Arduino.

Step 6: Adjust the Sensitivity of the Sound Sensor

To adjust the sensitivity of the sound sensor. Turn the trimmer anticlockwise until the built in red led is not glowing. Slowly turn the trimmer clockwise until the built in red led is starts glowing. this is how to adjust the sound sensor.

Step 7: WARNING ABOUT THE NEXT STEP.

IF YOU DONT HAVE ANY EXPERIENCE IN MAINS VOLTAGES PLEASE DO NOT TRY THIS AT HOME AS 220 VOLTS OR 110 VOLTS AC CAN BE LETHAL. DO THIS PART AT YOUR OWN RISK.

PRECAUTIONARY MEASURES

WEAR RUBBER GLOVES WHILE WORKING WITH MAINS VOLTAGES.

WEAR EYE PROTECTION GLASSES

PAY ATTENTION TO WHAT YOU ARE DOING

Step 8: WIRING UP MAINS WIRES TO RELAY MODULE

CONNECT THE EARTH WIRE OF THE POWER CORD TO THE EARTH TERMINAL OF THE AC SOCKET.

CONNECT NEUTRAL WIRE TO THE NEUTRAL TERMINAL OF THE AC SOCKET.

CONNECT THE LIVE WIRE TO THE COMMON TERMINAL OF RELAY MODULE AND CONNECT A SHORT PIECE OF WIRE TO THE NORMALLY OPEN TERMINAL OF RELAY MODULE TO THE LIVE TERMINAL OF THE AC SOCKET.

Step 9: TEST THE CIRCUIT

TEST THE CIRCUIT YOU HAVE CREATED WITH A SAFE DISTANCE LIKE MAINTAINING SOCIAL DISTANCE WITH OTHER PEOPLE. IF IT WORKS FLAWLESSLY THEN EXPOSING ALL THE MAINS WIRES IS BAD. USE A CASE TO PROTECT YOURSELF AND OTHERS.

Step 10: Choosing a Case

I prefer to use plastic case because you can hot glue to glue the components down without worrying whether components would short. If you like the looks of a metal case then go for it but my only regret is that

  1. They are expensive for a box to hold board and wires
  2. We need to ground the box to prevent others death and
  3. we cannot glue down any components with hot glue and the THT (Through Hole Technology) components can be shorted because of exposed metal. Use layer of plastic sheet and place a cardboard on top of it and another layer of plastic sheet like a burger that tastes less. But helps to smell good not making smoke. My choice is to use an acrylic sheet as it is tough and does not make a hole and short the components. But two choices are good.

Step 11: My Case Choice

My case choice is different. I used wood. I know its a box of fire but it does not generate heat to catch on fire. Bonus points to wood. Its not conductive unless you put it on water and glue can stick to it. I would give it the 2nd place. The first goes to plastic because of its versality. The second place goes to wood because of its cost and ease of use. The 3rd place goes to metal box because of its annoyance to the user if not grounded properly and usability.

Step 12: USE a FUSE

Use a fuse holder with a proper fuse to match the rating of the device. you can plug a device which can draw up to 10 amps which is in 220 volts is 2200 watts but I recommend you to use a device which draws less than or equal to 2000 watts because the relay contacts would wear out easily. The relay I use for this project is only 10 amps so I used a 10 amp mains cable and 10 amp fuse to blow up if I draw more than 10 amps.

Step 13: Power Supply for Arduino

Before we were using mobile phone charger as the power source to the Arduino, the relay module and the sound sensor module. But i wanted all the electronics in the box itself. so disassembled an old phone charger, rescued the circuit inside and soldered live and neutral wires to the live and neutral pads of the charger. Solder two wires to the output of the charger and solder it back to the VIN pin and the GND pin of the Arduino.

Step 14: FINAL STEPS

CONNECT THE CIRCUIT ACCORDING TO THIS DIAGRAM. USE HOTGLUE TO SECURE ALL THE COMPONENTS. CLOSE THE BOX WITH SCREWS AND THIS PROJECT IS FINALLY COMPLETE.

IF YOU LIKE THIS PROJECT THEN LIKE SHARE AND SUBSCRIBE TO MY CHANNEL CLICK HERE TO SUBSCRIBE

TO WATCH MY PREVIOUS VIDEO CLICK HERE