Electret Microphone as an on off switch...

So I have this nice little microphone from sparkfun:


The original idea was to use this as a go/stop switch for my little robot I am building with my daughter. I open an analog read to pin 5 (where the aud is plugged into) and read the value, and if its over some threshold I toggle the motors on or off.

It became readily apparent that using devices with microcontrollers are a whole nother ball of wax. The above didn't work as intended, sure the motors were off until the microphone "heard" a clap. (Actually that doesn't work right, I have to be right by the microphone and basically tap it for it to register..).

So I got it working where this "clap" would star the motors, then the idea was another clap would stop motors. Well problem 1 was that when motors are on the ambient noise goes up. Secondly, tapping the microphone (simulating the needed volume height for a registered "clap") doesn't stop robot or sometimes registers as a two sounds (so shuts it off then on). I am wondering if this micorophone as a switch idea is even possible is it? got the idea from those radioshack walker bug things where you clap and the little walker goes in reverse.

So is my idea feasible or do I need more circuitry, I know I am new to all this world of arduino and robots but on paper the problem set didn't seem this difficult. I could goto a push button switch, but wanted something easy for the kiddo to control. I did find some code where the same microphone controls LED lights based on the music it hears... there is some averaging of data going on...


I think partially the problem is realizing the delay(100) command seems like a no op, not a pause in actual execution, so If I delay 100 to not pick up a ton of values from the microphone, then the delay also effects the motors firing off or on too?

Any insights on these would be awesome, thus far though the project has been quite fun! Shane

Thanks for your detailed and nice response. I am going to research this, it is indeed far more complicated than I thought it would be but its a good way to learn more. I don't have oscilloscope but I will definitely try to look at the values and research more on the rectifier and diodes. Thanks alot!

Hey guys. I am using mics in a similar project, and I what you were saying about smoothing the waveform got me doing some research into rectification circuits. I found one, however, that used an induction coil, and that made the smoothing effect after the first capacitor nearly perfect. I just don't understand why or how this coil helps things. Would it be too confusing to describe to me? I have some experience in physical properties, so don't be afraid to use the big words. :P Thanks.