Sound detector

I have been so busy at work that I couldn’t update this blog for some time. I can’t believe it’s already October!

A few days ago, I was looking for something in my junk (but goodies) drawers in the basement, where my small working table is, when I saw a few different sizes of condenser microphones (aka electret) which I don’t even remember where I took them from. Probably from old computer’s microphones or cellphones.

Anyway, I got an idea to make something fun with them. You may have heard or seen the commercial of a clapping light switch. I thought I could make it easily and use it for many other applications such as night security system or sound activation switches or something like that. So I started looking for parts again from my junk drawers.  First thing came to my mind was simple one transistor amp like the one below I found from google image search. If you search keywords like “mic amplifier circuit,” you will find similar ones easily.

I remember I have built one like this long time ago but I don’t recall whether it worked properly or not. Anyway I built one quickly on a bread board and tested the output using an earphone. Well, it was not good enough to trigger any circuit.  So I added another stage of the amplifier.  With this addition, the effect was clear and amazing.  I could even hear rustling of my sleeves and keyboard typing loudly. Now I removed the earphone and connected the output to the analog pin 5 of JeonLab mini v1.3 and read the signal. The result was not as good as I expected. It was very noisy and there was no difference between the background level and any sound like clapping. There are a few reasons I could think about. It could be the poor quality power source from USB (since I needed to use FTDI to read the numeric values, the power for the mic amp, JeonLab mini, and the FTDI board were all connected to the USB. Another reason might be frequency range of the mic. If it is so wide and pick up all the low and high frequency noise that human can not hear, that would mess up signal reading. In that case, I would need a band pass filter. One more thing I could think of was the different impedance between the earphone and the ATmega328 chip analog input pin.  Anyway, I have tested all the possibilities mentioned above and found it was combined case.  Finally, I connected two supercap (2.7V, 10F each) which is one of my favorite power source and added two resistors and a capacitor as a low pass filter as shown below.




The result was very satisfactory. It could be activated well enough for any sound (e.g. talking or any sound around us) and lit the LED(#13).

Here is the Arduino code.  It’s very simple program that reads analog pin 5 and if it exceeds certain level turn the LED #13 on.  As for the threshold (5 in this case), you need to find a proper number by trial and error. This value may be different for your set-up depending on the type of microphone or band pass filter you want to use.

 Sound detector: LED
 Created: Sep 27, 2011
 Modified: Oct 3, 2011
 by Jinseok Jeon

#define micPin 5

void setup() {
  pinMode(13, OUTPUT);

void loop() {
  if (analogRead(micPin) > 5) { //try 5-50
    digitalWrite(13, HIGH);
    digitalWrite(13, LOW);

The circuit diagram is as below.
Sound detector circuit

There are two stages of 2N3904 (npn transistor) based simple amplifier and noise filter at the output of the amplifier before it is send to the JeonLab mini analog pin 5. You may find the sensitivity might be different from mine if you use different type of microphone.  If that’s the case, I would suggest to do some experiment with those values of the filter circuit (C4, R7 and R6).  I have tested with a few different sizes and models of the microphone and found all of them worked fine with the circuit above. As shown in the above picture, I used a 100 ohms trimmpot for the R7, but you can use any value between 10 and 100 ohms. There are no big difference with this resistance.

As a tip to monitor the signal coming in through the analog pin 5, I used the Poorman’s oscilloscope and it worked really well.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s