# The Viciously Simple Clap-ON Clap-OFF Circuit for Arduino

34,065

62

10

Hi Everyone!

I've had a few people ask about creating a simple clap-on/clap-off circuit using Arduino. Well those who are interested are now in luck. The software in this instructable is simple and well commented. The schematic is simple, and the components are easy and inexpensive to acquire! All you'll need are 6x components, and an Arduino UNO. I hope that this helps those of you who need to build this for one reason or another. In this instructable, the circuit acts to simply toggle an LED on and off for ever clap. You can use a relay circuit instead if you'd like, or you can simply take the code in this instructable, and manipulate for your specific application. You can easily calibrate the sensitivity in the code to your level of satisfaction, and the circuit can be put together in minutes! The schematic and the code are explained in the below video, and in the following sections. I hope that you find it fun and educational!

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: The Schematic Diagram!

The circuit is simple! You will need the following components:

2x 10k ohm resistors

1x 300-600 ohm resistor

1x Electret microphone

1x LED (I used a 3mm red LED)

1x 0.1uf ceramic capacitor

Lastly, you'll need an Arduino UNO.

Let's talk about the audio circuit. What we need to do is block the DC component from the microphone circuit, but couple the AC signal across the 0.1uf ceramic capacitor. The capacitor blocks DC, but accepts AC signals. When you make a noise, the audio signal is coupled across the capacitor, which is connected to the A0 pin on your Arduino. The louder the clap, the higher the amplitude of the coupled signal The secondary 10k pull down acts to bleed off any power built up on the input/line capacitance. Without it, the circuit won't work properly. You will need to use the 5v pin and the ground pin on your Arduino to supply power to this circuit. I used an ICU-Duino Arduino Shield for this project, as it had a prototyping area. You don't need to use this.

The LED circuit is very simple. You simply need a resistor with a value of 300 to 600 ohms and an LED. The resistor acts as a current limiter, which protects the LED from taking too much power from the source, which is pin#2 on your Arduino.

## Step 2: The Code!

The Script Can Be Found Here:Clap Script

The link above is to my code samples page on my website. Look at the bottom of this page for the script download. The Code is also pasted below. It is explained in detail in the video, but I've also ensured that it was commented in full. It is pretty straight forward.

One thing that I'd like to note is that you can calibrate sensitivity with ease! I've added in a serial print function that allows for you to see the returned values every time you clap. This will give you an idea as to how to change the sensitivity in your code. The higher the compared values, the lower the sensitivity. I use a compare value of "8" in the code. If you make it 15 or higher, then the sensitivity will be low. If lower than 8, it will be extremely sensitive. It is truly very easy to manipulate!

The Script:

## Step 3: Many Thanks!

I hope that you found this interesting and/or useful. Thanks for taking the time to look at my instructable.

If you're at all interested, my current kickstarter (Arduino Compatible Multi-Program Laser Tripwire Set) can be found here: Kickstarter Campaign!

You can find lots of other fun projects, kits, and turorials on my website: Engineeringshock Electronics

Thanks everyone! I hope that you're having a great weekend =D

Sincerely,

Pat

Participated in the
Teach It! Contest Sponsored by Dremel

Participated in the
Microcontroller Contest

Participated in the
Tech Contest

## Recommendations

• ### Internet of Things Class

22,724 Enrolled

## 10 Discussions

I can´t get it!! The LED is always blinking and I can´t find what is wrong...

Hi! Cool project.

Just wondering, how is this able to distinguish from coughs/sneezes etc?

thanks for such a nice projects

Thanks a lot for this awesome project. I have a question. I want to turn on two leds . if i clap once the first led will turn on and if i clap twice then the second led will be on. And in the same way, if i clap once the first one will be offand if i clap twice then the second one will be off. Plz help me. If i need to change the code then send me the code here in comments. Thanks again.

Greetings,
Prithul.

Dude thank you very much!

I wanted to use the microphone modules that are sold on Ebay for my project, but they did perform far worse than this simple schematic!

These aren't new but they seem to never age. Another great project. Good job

I was just thinking about implementing a clapper into a light switch or dimmer. I was experimenting with attiny projects and found that serial write functions aren't supported. looks like that part isn't necessary?

2 replies

Nope =) A relay is easily implemented with this circuit. You could program the Arduino to work with a high powered FET/PWM for dimming =) It just requires some extra hardware, and some minor software changes.