The Clapper was a popular gadget in the ’80s and ’90s. 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, eliminating false triggering and letting 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 router off for ten seconds and then turn it back on automatically. Or, you could turn a heater on for a few minutes and have it automatically turn itself off.

Project Steps

The Circuit Design

The circuit for this project can be divided into two main parts: 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 connects pin 2 to GND when in normal operating mode and connects the pin to 5V to change to programming mode.

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. The only changes that you may need to make are the threshold value that sets the sensitivity of the sensor.

Prototype the Circuit on a Breadboard

As with any electronics project, you should prototype the circuit on a breadboard 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 has been installed in the insulated project enclosure. Having exposed connections with 120VAC is very dangerous.

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.

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 set the wires and the switch in their slots and secure them in place with hot glue. Once everything is in place, close up the housing.

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

Control Your Appliances with a Clap

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 it back on. The only limitation is your imagination.

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 connections are properly insulated.