Cheap Sound Sensor for AVR

Alexander Weber

I searched the web for a cheap method to let the ATmega respond to sound. My knowledge in analog circuits is very limited, but what I do remember, is that you can not attach a electret mircophone to a controller pin. The signal of the microphone is just too small and has to be amplified. There is much of information out there, especially on diy amplifiers. I stumbled upon this little circuit here. It consists only of a handful of components:

  • 2 resistors 10k
  • 1 resistor 100k
  • transistor 2N3904
  • 2 capacitors 0.1u
  • electret microphone

Prototyping the amplifier

Putting things together on a breadboard.

Actually I had no 2N3904 around, so I replaced it with a BC337. The circuit is a emitter circuit with voltage degeneration (I dont know if that exists in english). I dropped the couple capacitor and took the signal right away at the collector.

Prototyping with the ATmega

The sound sensing is done with the ADC of the ATmega. A simple program reads the analog value of the amplifier over and over. If the value (loudness) exeeds a specific level, an LED is lit.

The schematic for rebuilding

The code can be found here mic_sensor.c. It is just hacked together and has lots of room for improvements.

Video

Here is a video that I made. Has lousy quality, for both, video and audio.



Click To Play


Conclusion

It was easy and worked pretty well. I enjoyed looking at the LED responding to the music. I haven’t recorded anything with this amplifier, it might sound awfull. Next steps could be playing the sound back or be able to analyze the sound (FFT). And (re-)learning more on analog circuit design.

tinkerlog.com