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 =)

Step 1: PART LIST:

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.

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

Can somebody please tell me how to design a clap switch which turns on by two claps and turns off by one clap?
<p>You have to code like that in 555 timer. For example for a electrical input you need to clap twice else reset the code right? After turning on circuit you need to code it to input signal when you clap only once.</p>
<p>hey can i connect it to a 220V source with same specifications of the circuit or do i have to change the resistors ?? </p>
<p>i want to use my arduino uno as microcontroller because i havnt worked on PIC10F222..</p><p>so, can I ?</p>
<p>This is a simple one clap switch circuit using 555 Timer</p><p><a href="http://electricaltechnology.org/2014/10/clap-switch-circuit-electronic-project.html" rel="nofollow">http://electricaltechnology.org/2014/10/clap-switc...</a></p><p>I hope it will help you... </p>
<p>I'd much rather build a circuit that uses the venerable ol' 555 and a tank circuit to time it. There's too much &quot;reach for the PIC, 'cause that sounds like a logic circuit to me&quot;- A $.50 circuit with $20 worth of supporting electronics. (I exaggerate, but not by that much!)... The timer doesn't need a PC and a programming puck - easy to wing it.</p>
<p>Thanks Bro </p>
<p>I just made this:</p><p><a href="https://www.instructables.com/id/The-Viciously-Simple-Clap-ON-Clap-OFF-Circuit-For-/#" rel="nofollow">https://www.instructables.com/id/The-Viciously-Simp...</a></p><p>I hope that you find it helpful!</p>
hey guys I need some help<br>my led goes automatically of after 5-6 seconds......how to fix it????<br>plzz reply
<p>Hello EngineeringShock! <br>Loved the detailed explanation with all the steps and schematics <br>Is it possible to make a HARDWARE ONLY triple clap on/triple clap off circuit based on this one? If so, how? <br>Thank you :)</p>
<p>i cant understand the complete schematic in step 6 .. anybody can explain .. ? thanks</p>
<p>Nice Instructable. How close are you to the microphone when you do this?</p>
do you have some scheme to connect it on 230V (or 110V for America) , or you can do it with that circuit then just connect it to some relay which will work as switch?
<p>Have you found an answer to your question? Because I'm going to use a 230V instead of a 9V and I'm wondering if I have to change something...</p>
<p>Yes, you can connect it to 230V with no problem, but under condition that you have 5V power supply for your circuit and relay ( if you're using the one which works on 5V) , on relays you can attach up to 380V(I think they are rated to this voltage) </p>
<p>can you please send me the hex file? I'm lost with asm compilation...</p><p>I really don't understand how to compile it. It will be awsome if you could send me the hex file</p><p>romainhuon514@gmail.com</p><p>thanks!</p>
<p>great post. Another alternative if someone does not want to program and code ; we can use a counter like CD4017 which counts the claps from LM324 output, and you can easily set 2 or 3 or even 4 claps on or off.</p>
U made one ?<br>
<p>good day all ..</p><p>thanks a lot for the great work, but I only have one question; what is the use of </p><p>100k Ohm Multi-Turn Potentiometer ? </p><p>thanks a lot and will be waiting for your answer :D</p>
<p>Seems that the code up there is not working Pat.</p><p>Assembler Code build failed</p><p>Can u make a video of compiling the code and share it to us Pat?</p>
Hello! I made the circuit but I have a question. What pins of 10f222 I have to use to programming it; I don't know very well the programming stage of circuits. Thank you!
Sorry for taking so long to get back to this, guys. I don't have the hex file available. Just the code posted in the instructable =( <br>Sorry! =(
Will it turn off by itself? If yes, how could I keep it from turning off by itself?
Hello! I'm new to electronics and was looking to make something like the clapper but that responds to other sounds. Does anyone know how to make one?
<strong>Nice instructables</strong>, 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 .&nbsp;<br> As what i understand, this clap switch can detect&nbsp;false&nbsp;triggering from claps where it <strong>protects your circuit from turning on and off due to&nbsp;unnecessary&nbsp;sounds or&nbsp;unintended&nbsp;sounds or claps</strong>.<br> Very nice clap circuit actually but needs some programming.<br> <br> I have a <strong>circuit </strong>here from my friend and very <strong>good for&nbsp;beginners&nbsp;like me</strong>, i guess. just see the diagram below if you are&nbsp;interested. &nbsp;If you are interested only.<br> <em>copied from:&nbsp;<a href="http://www.simple-electronics.com/2010/11/clap-activated-relay-or-switch-220v.html">http://www.simple-electronics.com/2010/11/clap-activated-relay-or-switch-220v.html</a></em><br> <br>
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!!!
True, but markee2's have more possibilities to use it in practical sense. Ofcourse you have to know how to protect your self and circuit to make something like that with some level of protection, otherwise you are just like bookie.
would be glad if you send me the pic program for the circuit,email me at pdnashe@gmail.com
Sir please Teelll mee The Apllication for this clap detector....???? please reply here fast......
I did it without software, using a 555 timer as a monostable multivibrator and a JK flip-flop. BUT I have a problem. <br>The out of the comparator is a VOLTAGE signal, and the 555 timer is activated with GROUND..... how am I supposed to connect this 2 circuits???? =S <br> <br>PLEASE HELP!
you need to switch the input to the lm324, between the voltage from the divider and the signal comming from the mic. (This is the comparation stage of the LM324, not the amplification stage) <br>May be this links can help you a little bit <br>http://en.wikipedia.org/wiki/Comparator <br>http://home.cogeco.ca/~rpaisley4/LM555.html
I did it with a different uController, thanks for your post, it helps me with the electret mic. <br>http://youtu.be/4OuOy0e1VSY
Hi. Just need to check...is there a missing resistor to the right of the dc blocking cap that connected to 5v since this is a single rail supply?
hi this project is somewhat similar to my project by i am using different microcontroller...is it ok if i ask for the codes??? please email me at dbuot63@yahoo.com. <br>thanks
hi im currently going to LTI and i want to do this for my final project. the only problem is our school can only program 8251 microcontrollers or chips like that. is there a chip that is equivalent to the one you used that i could get instead? please email me at dmfbaseball92@yahoo.com. <br> <br>Thank you.
Hello, I really like your circuit and code, but could you please tell me where in code can I increase the time interval for detecting second clap? I would like about 1s interval. Thanks
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 <br>
Hi Patrick <br> <br>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. <br> <br>Thanks a Million <br>Riyad
do you have the code for 16f628a
Where are you using the LM78L05 Mini 5v Regulator?<br><br><br>Can i do the circuit without this component?<br><br>I like the circuit you made. It is simple and very understandable.
Thanks! <br>If you look at the upper right hand side of the board, you will see a transistor and the regulator. They have the same package.
Thanks, a few days ago I did the circuit and it worked great! Thanks for all your help.
Sorry, I got it, you are using this in the power supply. <br>Anyways, why using the LM78L05 instead of using a resistor to resist 9v into 5v?<br><br>Can I do the circuit without this component ? Because I live in Argentina and it is hard to get this kind of things here.<br><br>Thanks for all, and sorry for my bad english.
Great circuit! I did this with an Arduino, but that's just an overkill..<br><br>Is it okay if I use a 5.7 volts power supply, and skip the voltage regulator? Or is it too much.<br><br>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?
Hi <br>Thanks! I'd not change 5.7v. I'd use the regulator. However, a 7805 reguires about 6.5v-7v minimum to regulate properly to 5v. <br> <br>I just completed a better version of this circuit that does not require an amplifier. <br> <br>The sensitivity of this circuit is cased on your amplifiers. You can adjust them for your required sensitivity. <br> <br>
can this be done with a ir reciever and transmitter?
What is the purpose of the 5V pullup on the electret? Is the DC biasing really necessary?
It is extremely necessary. You are protecting the microphone through current limitation. The resistance of the microphone is about 1k ohms when there is no noise being detected. I have never seen a microphone circuit that has a mic connected directly to the power line. <br><br>I don't think you'd see much at the secondary end of the coupling capacitor if you placed the microphone between5v and ground, with the coup0ling capacitor connected to the power line as well.

About This Instructable




Bio: 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 ... More »
More by EngineeringShock:The Viciously Simple Clap-ON Clap-OFF Circuit For Arduino The Multi-Program Laser Tripwire Set - Video User Manual! Creating A Resistor Based Keypad & Interface With Arduino! 
Add instructable to: