Help! Sound detector for library

Hi my library asked me (lol) if i can make a sound detector turning one of the 3 leds for different levels of intensity

Green-> 40dB and less
Yellow->41 dB and up
Red-> 51 dBand up

The reason behid it is to make people conscious of the level of their speech inside the library (many people are upset of this) that's why i've been asked to make something for some sort of visual image for them.

it is my first time picking up an Arduino, so i beg you to explain me simple stuff.
i don't know much about programming but i learn things quickly and i really want to help my school out.
i appreciate anything you can say to me to start this project.
Love, Nick

You could make a start by Googling "Arduino Sound Level Meter" and similar phrases.

Steve

Or, search this forum for "SPL meter".

it is my first time picking up an Arduino, so i beg you to explain me simple stuff.
i don't know much about programming...

Do you know any electronics?

It isn't "hard" to make a basic sound level meter (or to adapt it to trigger 3 LEDs) but it is hard to make a good-calibrated one. You can read some of the previous related on the forum for more details.

...I'll give you some hints & tips to get you started -

----HARDWARE----
You can buy a microphone board with an electret microphone and preamp. There are 3 types of microphone boards (or some with 2 or 3 different types of outputs).

A basic microphone board gives you an amplified audio signal that's biased at 2.5V. It's biased because the Arduino can't read negative voltages. With silence at 2.5V, it will read about 512 (half of the Arduino's 10-bit range). You can easily subtract-out the bias, but since you're reading a varying audio signal with a frequency up to nearly 20kHz you need to sample (read) the signal thousands of times per second (or as fast as the Arduino can loop) and then take a short-term average or peak.

A better option is a board with an "envelope" output. This is a varying (non-biased) DC output that's proportional to the "loudness". With that type of board you can read the signal at something like 10 times per second (or so) and you may not need to average.

There is a type of board that has a binary digital output (0V = logic 0 or 5V = logic 1) when the sound level is above/below a threshold set with a pot. That type of board will NOT work for you because you need 3 (or 2) thresholds.

----SOFTWARE----
Take it one step at a time!!!

Once you've got the microphone board plugged-in, run the [u]Analog Read Serial Example[/u]. You should get some "random looking" numbers that jump-around with sound. But, you should get some bigger numbers with louder sound. Assuming you're using a "regular" microphone board, you'll get small numbers with loud sounds too (because any sound wave crosses-through zero twice per cycle and is negative half the time). But, the highest-peaks should be higher with loud sounds.

It may be helpful to generate some test tones or white/pink noise on your computer to get consistent results. (You'll still get random-looking results but peaks should be more consistent.)

Now, you're going to need a real already-calibrated SPL meter.

Take a reading on the SPL meter and compare it to a peak reading on the Arduino ADC. That's your calibration reference. (dB is a ratio and you can't calibrate dB without a reference.) If you don't already know how to calculate dB, research that. You'll be calculating a dB difference between the reference ADC reading and the current ADC reading, then you add/subtract to find the actual SPL dB level.

At this point you may want to start finding peaks (maybe take 20 or more readings and keep the highest reading) and you may want to take the delay out if you're still using the Analog Read Serial code.

Once you getting dB readings you can add the LEDs and some if-statements to turn-on the LEDs if the dB threshold is exceeded. (And first, you might want to try a little test program to turn-on the LEDs one-at-a-time to make sure they are working.)

Sound propagates via an inverse-square law. If you're twice as far away, then the sound level is one quarter. The dB scale mitigates some of this as one quarter is about 6dB.

Soft sounds close to the microphone will show up much louder than loud sounds further away.