3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

How to make a Clap-Clap on / Clap-Clap Off switch circuit!

How to make a Clap-Clap on / Clap-Clap Off switch circuit!
Hi all!
This instructable not only gives the reader the information needed to create a clap-clap on/clap clap off switching circuit, but the logic used to make a hardware-only clap-on, clap off circuit.  More information on a hardware-only version can be found in the final section of this instructable.

This circuit employs some very simple and cheap circuitry, and a simple program. It is relatively easy to make a hardware only clap on/off circuit, but I wanted to create a circuit that required two claps to switch on, and two claps to switch off.  The claps must be in quick succession, as seen in the video below, or else it does not work, which is the entire point of the circuit =)  I will go into detail about the circuitry, and the program.  I will also do my very best to answer any questions you guys may have.  This device can be thrown together in a single evening.

The software works like this:
1) The software waits for an initial loud noise, then starts a countdown sequence.
2) If the device detects another loud noise within about 250 milliseconds, then the relay will toggle on.  If the timer runs out of time without detecting another loud noise, the program resets.
3) Once two claps have been detected, and the relay toggles on.  The software then starts the same sequence over again, only waiting to toggle the relay off. 
4) Once the relay toggles off again after detecting two claps in succession, the program resets back to the original state.

Since the PIC10F222 has a limited instruction set, I had to add in some extra lines of code.  I would have used the PIX18F1220, but that would have been over-kill.  Ah, but how I miss the BTF (Bit Toggle) instruction =)
 
Remove these adsRemove these ads by Signing Up
 

Step 1PART LIST:

PART LIST:
HARDWARE:
I'll start of by giving you guys a part list.  The box and the screws are not necessary for this project, but I'll add them to the list.

PART LIST:
1x  Prototyping board (Roughly 1" by 1") or bread board.
1x 9v Connector
1x LM324 Quad Op-Amp IC
1x LM78L05 Mini 5v Regulator
1x PIC10F222 Micro controller
1x Electret microphone
1x 5v Relay SPDT or SPST
1x 2N2222 NPN Transistor
2x 0.1uF Ceramic capacitors
1x 1N4001 Diode
1x 100k Ohm Multi-Turn Potentiometer
1x 100k Ohm 1/4W resistor
2x 10k Ohm 1/4W resistor
1x 3k Ohm 1/4W resistor
1x 7k Ohm 1/4W resistor
1x 1k Ohm 1/4W resistor
1x Project Box
 

« Previous StepDownload PDFView All StepsNext Step »
31 comments
May 26, 2012. 3:15 AMkrrran000 says:
I am Karan Shrestha And I wnt to build it but I dont know how to use the software. I m reading in class 11. Please help me. My email is krrran000@gmail.com or brokenheart418@gmail.com
May 24, 2012. 6:46 AMYadi786 says:
Hi Patrick

My name is Riyad, I am currently building a clap switch circuit that I found on the internet for University but it is a single clap switch and I would like to change it to a double clap the hardware way but I don't know hoe to do this. Can you help me please? I don't have much time left as it is due 3days time. My email is riyad.abrahams@gmail.com if you are able to email me I can show you what circuit I am using.

Thanks a Million
Riyad
Mar 25, 2012. 5:19 AMnodoubtman says:
I modified the code, if anyone want the .hex file just msg me!

Cya!
marC:)
Oct 11, 2011. 7:46 AMtt4455 says:
do you have the code for 16f628a
Sep 14, 2011. 1:59 AMmarkee2 says:
Nice instructables, but the project needs some engineering background i guess , or needs higher level of intellect in electrical or electronics, where ordinary hobbyist like me cant understand . 
As what i understand, this clap switch can detect false triggering from claps where it protects your circuit from turning on and off due to unnecessary sounds or unintended sounds or claps.
Very nice clap circuit actually but needs some programming.

I have a circuit here from my friend and very good for beginners like me, i guess. just see the diagram below if you are interested.  If you are interested only.
copied from: http://www.simple-electronics.com/2010/11/clap-activated-relay-or-switch-220v.html

Sep 24, 2011. 8:19 PMMROHM says:
Isn't Patrick's Battery Operated circuit More Safer since He's Using A 9 Volt Battery???? Your Friend's Circuit uses 220/120 Vac which I believe is a little Dangerous for a Beginner!!! Until you get a little Experience in Electronics I would Suggest You stay with 9 Volts!!! If you still want to Dabble with Line Powered Projects get yourself a Variac/Isolation Transformer So that You can Test Your Line Powered circuit at lower ac voltage Levels,,,safety First!!!! A Variac is a Variable Ac Voltage Transformer while a Isolation Transformer Can Prevent Accidental Shocks If By Chance You Touch a Metal Chassis(Especially in Old Tube radios) It scares me half to DEATH why there are Instructables that have plans to restore tube radios WITHOUT the Use of a Variac/isolation tranformer. Remember 120/220 Vac will respect You if You respect it!!!
Jun 16, 2011. 2:19 PMleandro0012 says:
Where are you using the LM78L05 Mini 5v Regulator?


Can i do the circuit without this component?

I like the circuit you made. It is simple and very understandable.
Jul 4, 2011. 2:42 PMleandro0012 says:
Thanks, a few days ago I did the circuit and it worked great! Thanks for all your help.
Jun 17, 2011. 12:48 PMleandro0012 says:
Sorry, I got it, you are using this in the power supply.
Anyways, why using the LM78L05 instead of using a resistor to resist 9v into 5v?

Can I do the circuit without this component ? Because I live in Argentina and it is hard to get this kind of things here.

Thanks for all, and sorry for my bad english.
Jul 3, 2011. 4:38 PMFallenSub says:
Great circuit! I did this with an Arduino, but that's just an overkill..

Is it okay if I use a 5.7 volts power supply, and skip the voltage regulator? Or is it too much.

Also, how sensitive is this device? Will it work fine on a few meters range indoors without the need to clap like a mad man?
Jun 17, 2011. 5:40 AMjbouffard says:
can this be done with a ir reciever and transmitter?
Feb 7, 2011. 3:58 PMzeneslev says:
What is the purpose of the 5V pullup on the electret? Is the DC biasing really necessary?
Feb 7, 2011. 9:28 PMzeneslev says:
What I mean is: why do you need to tie the electret to 5V through the 10k resistor? Why not remove the 10k and the 5V source before the coupling cap? All you are interested in is the non dc "small signal" to propagate through the amplifier.

Thanks.
Jun 4, 2011. 4:25 AMbetoroma says:
you could build with clap pi 10f222
I can not compile the program
thanks
roberto
 betoroma@ig.com.br
Feb 8, 2011. 10:40 AMzeneslev says:
Ah, I wasn't aware of the built-in FET. That would definitely require DC biasing. http://en.wikipedia.org/wiki/Electret_microphone

Nice project!
Jun 4, 2011. 4:21 AMbetoroma says:
you could build with clap pi 10f222 I can not compile the program thanks roberto
May 6, 2011. 4:49 AMssanthosh says:
I want to ask that if this will work on AC Volt Input ?
if it work on AC Volt Input can i light up a CFL bulb in Output?
Apr 21, 2011. 12:43 AMnmc6903 says:
thanks for sharing this project. But I want to replace 10F222 by 12F675 so how can I edit the code for compatibility.

thanks

my email : nmc6903@yahoo.com.vn
Apr 1, 2011. 12:31 PMsmartieblonde219 says:
To use the software-less circuit does the circuit you describe there go in place for just the "brain" and then you still need to connect it to the relay switch?
Mar 3, 2011. 5:30 PMBIGHAIRYDUDE says:
how much did this cost you and could you use it with high voltage like in a normal light switch in the wall
Mar 4, 2011. 1:19 PMBIGHAIRYDUDE says:
but what if i was just to do it buying one piece at a time about how much?
Mar 10, 2011. 10:19 AMleandro0012 says:
First of all, thanks for sharing this nice instructable. Secondly, Can I use another PIC microchip? Sorry for my ignorance.
I'm asking this because in Argentina it's very difficult to get the PIC10F222 Micro controller. Do you know any china store with this microchip and worldwide shipping?

Thanks a lot.

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
70
Followers
22
Author:EngineeringShock(engineeringshock.com + More!)
Hi there! My name is Patrick, and I am an electronics engineering technician who works full time as a lab tech, and part time as an electronics engineer/salesman. I own an ebay store, and two website...
more »