Introduction: Sound Activated Outlet

The Clapper was a popular gadget in the 80's and 90's. It let you turn appliances on and off just by clapping. This can be pretty useful, but it has some limitations. First there is the problem of loud noises accidentally turning the lights off. Also, you can't control multiple outlets independently of each other.

So I decided to make programmable version of the Clapper using an Arduino microcontroller. The Arduino lets you set codes for each outlet. This eliminates false triggering and lets you control multiple outlets independently. Your lamp could be turned on and off with one clapping pattern and your fan could be controlled with another pattern.

The Arduino also lets you program how the outlets are turned on and off. For instance, if your internet router needs to be reset, you could program it to turn your internet router off for ten seconds and then turn it back on automatically. Or you could turn a heater on for a few minutes and automatically turn itself off.

Step 1: Watch the Video

Here is a video walkthrough of the project.

Step 2: Materials

Here are the materials and tools that you will need for this project.

Materials:

Arduino microcontroller

Electret microphone

2 x 10 kohm resistor

100 kohm resistor

3 x 100 ohm resistor

0.1 microfarad capacitor (capacitor code 104)

White LED

Red LED

Green LED

Small Switch

Jumper wires

Power MOSFET (such as IRF510)

Diode (rated for at least 1 amp)

5 Volt Relay

Extension cord

printed circuit board

Insulated project enclosure

5V power supply/ USB charger

Tools:

Soldering Iron and solder

Wire Cutters

Wire Strippers

Knife

Screw Driver

Step 3: The Circuit Design

The circuit for this project can be divided into two main parts. There is a microphone assembly and a relay driver.

The microphone assembly is composed of an electret microphone element, two resistors and a capacitor. When the microphone picks up sound vibrations, the output voltage fluctuates in response. This signal is sent to one of the analog input pins on the Arduino.

The relay driver is composed of a power MOSFET transistor, a diode and a relay. The power transistor is added because the relay requires more current than the digital pins on the Arduino can output. So the output signal that is sent from the digital pin activates the transistor and the transistor connects power to the relay and turns it on. The relay either connects or disconnects power from the AC outlet to the attached appliance. The diode acts as a suppression diode and protects the Arduino from voltage spikes that occur when the relay is turned off. If you don't want to build a relay driver from scratch, you can use a commercial relay shield or a PowerSwitch Tail.

If you want to be able to reprogram the clap pattern without modifying the code, you can connect a switch to digital pin 2. This switch connect pin 2 to GND when in normal operating more and connects the pin to 5V to change to programming mode.

Step 4: The Code

Here is a copy of the code that I used for this project. Most of this code was adapted from "The Secret Knock Detecting Door Lock" by Steve Hoefer.

You should be able to just download the code file, and upload it to your Arduino without any modification.

Step 5: Prototype the Circuit on a Breadboard

As with any electronics project, you should prototype the circuit on a bread board before soldering it together. This gives you a chance to make any necessary adjustments to the part values or the variables in the code.

First I tested just the microphone assembly with the Arduino. To test the output, I connected LEDs to digital pins 3 through 5. These indicate when the claps are detected, if the pattern is correct and when the output is activated.

You will most likely need to adjust the sensitivity of the clap sensor. To do this, you can change the value of the "threshold" variable in the code.

Once you have the microphone assembly working properly, you can add the relay driver. This part of the circuit rarely needs any adjustment.

SAFETY NOTE: Do not connect AC to the extension cord until the board have been installed in the insulated project enclosure. Having exposed connections with 120VAC is very dangerous.

Step 6: Solder the Circuit Onto a Printed Circuit Board

Once you have the circuit working, you can solder the parts onto a printed circuit board or a perf board. Then connect the board to the Arduino with jumper wires.

Step 7: Mount the Parts Inside an Insulated Project Enclosure

We need to mount the parts inside an insulated project enclosure. It is important that the housing be electrically insulated because we are working with 120VAC.

To mount the boards to the inside of the housing, I used hot glue.

Next, we need to cut some holes for the cables. Position the cables and the switch where they will be mounted. Then mark their position on both sides. Then using a knife or fine toothed saw, cut slots that are just big enough for the wires to fit through. Do the same for the program switch. Then I set the wires and the switch in their slots and secured them in place with hot glue. Once everything is in place, close up the housing.

In some cases it may be necessary to cut/drill additional hole in the housing to allow for sound to reach the microphone.

Step 8: Control Your Appliances With Sound

Now you are ready to control your appliances by clapping. Just plug an appliance into the female end of the power cord and clap out the coded pattern.

In addition to clapping, you can also activate the switch with any other loud noise. You can knock on the wall or the floor. You can whistle. Any noise that exceeds the set threshold can activate the outlet.

The default pattern in the sample code is "shave and a haircut." In the example given, the appliance will turn on for ten seconds and automatically turn off again.

You can modify how the output performs by simply rewriting the code to give the desired response. You can have the appliance turn on or off when signaled. You can have an appliance such as a heater or a fan turn on for a set duration. You can also use it to reset your router by turning the power off for ten seconds and automatically turning back on. The only limitation is your imagination.

Step 9: Optional Improvements

Because the outlet is activated by a specific pattern, you can independently control multiple outlets with the same Arduino. All you have to do is set up more relay driver circuits.

Another possible improvement that could be made on this design is to power the circuit from the input AC power cord. You could do this by simply moving the 5V USB charger to the inside of the enclosure. This would eliminate one of the external cords. You just need to make sure that there is enough room in the housing. Also make sure that the connection are properly insulated.

Comments

author
iamKYLEDG (author)2017-03-20

Can we put triac instead of power mosfet?

author

I don't think that you can activate a TRIAC with the 5V signal from the Arduino

author
Jasmeeet Singh (author)2016-06-24

Can you make this project by giving voice commands through the microphone??

author

It's possible. But good voice recognition would make the project a lot more complicated and might require a different microcontroller like a Raspberry PI

author

can you please give me your email id?? I want to talk about my project :) :)

author

If you want to send anyone a private message on Instructables, you can go to their profile page and click the box labeled "Private Message." This will let you send them a message on their site inbox.

author
SamL74 (author)2016-04-15

could you please copy the code so that we can see it and easily copy it?

author
ParthP18 (author)2016-03-06

In place of power mosfet. Put any mosfet. I will replace it myself. N name the led replacing mic. As microphone. Plz help. I really need ur help. Plz

author
ParthP18 (author)2016-03-06

In place of power mosfet. Put any mosfet. I will replace it myself. N name the led replacing mic. As microphone. Plz help. I really need ur help. Plz

author
ParthP18 (author)2016-03-06

I tried on working this project. I m weak on making circuit from circuit diagram. Plz. Do me a favour of giving me ur email id. Or can u make ur circuit on 123d.io this is an virtual circuit simulator. This simul. Does not have mic. So plz put led instead n share link to my email id. My email. LycanParth21@icloud.com Plz help. I need ur project as base of my another project

author
ParthP18 (author)2016-02-28

Hey. I m currently making this project but cannot find power mosfet. Can u suggest some alternative for it. Plz. Reply early. I have less time to finish this. I need it as starter for my other part of the project. Thanx.

author

If you can't use a MOSFET, you might be able to use a power NPN transistor.

author
ThomasVDD made it! (author)2015-09-16

I used an ATTINY and added a dimmer. Great project!

IMG_9187.JPGIMG_9183.JPG
author
Yonatan24 (author)2015-09-04

I bought an already working circuit for really cheap on ebay that is powered on 5V so I'll add a relay that works on 5 volts and is okay with 12 volts and I'll use it for my 12 volt LED strips for my projects table. Maybe I can also make an Instructable for that soon

author
YuryC (author)2015-06-05

Hello! Can somebody help me? My realization is not working. I watched scan oscilloscope and realized, that micro output signal is very low, when i clapped. But signal is high, when i blow on micro. So, how can i find a normal micro? Every micro, what i tried were identical. What can u advise for me? (Sorry for bad english)

author
yhdesai (author)2015-02-01

COOL

author
ZaidS (author)2015-01-29

Hey great project :D I'd love to make it, even though my knowledge in electronics is very limited. I want to know if there are any modifications to make if the power outlet is 220 V (European Electrical System). Thanks :)

author

Just make sure that the contacts of the relay are rated for at least 220V.

author

Thank you :)

author
Mr AbAk (author)2014-12-30

Nice Instructable

author
tomatoskins (author)2014-12-30

So many great memories of The Clapper! That's how we used to turn our tree on and off when I was a kid.

author
DIY Brothers (author)2014-12-30

Cool project

About This Instructable

20,579views

315favorites

License:

Bio: My name is Jason Poel Smith I am a Community Manager here at Instructables. In my free time, I am an Inventor, Maker, Hacker, Tinker ... More »
More by DIY Hacks and How Tos:How to Make a Festivus PoleAdd Wings to an Infant's Halloween CostumeBubble Bath That Never Runs Out Of Bubbles
Add instructable to: