Library noise level detector using 3 LEDS

Hi I'm doing a research about the library noise level detector. Here's how it works:
-When the noise is less than 40 dB the green LED will remain on
-When it is between 41-80 dB the orange LED will turn on
-and when the noise is above 80 the red LED will turn on together with the buzzer
(I'm using the ky-038 mic )

But the problem is I don't know the codes I'm just in middle school. Can someone help me with the codes I will put the name on our paper if someone helped me.
Thank you!

I'm using the ky-038 mic

Do you have a link to the datasheet or specs for that? (There are a few different "kinds" of microphone boards and the first page of Google hits didn't find the actual specs.)

If you need dB readings you'll need to calibrate with a real SPL meter. Then as long as the "character" of the sound is fairly-constant you can get reasonably-accurate readings. Making a real SPL meter is tricky so if you calibrate your homemade device with "library noise" it probably won't be accurate with a barking dog, etc.

Let's start with this: Are you hooked-up and can you get readings that correlate with loudness? i.e. If you run the code from the [u]Analog Read Serial Example[/u], do you see a difference with loud & quiet sounds?

Take-out the delay, and then I'll warn you that the readings will "look random" because you are measuring a constantly-changing wave (even with constant sound). But once in awhile you'll "catch" a peak of the wave and hopefully you can see a difference with quiet and loud sounds.

Most of these microphone boards have a biased output (so you can read the negative half of the AC audio voltage) so with silence you should read about 512 (half of the 0-1023 range). The louder the sound, the farther up-and-down your readings should "swing" from there.

If you can see "good readings", we can move-on from there.

This is one of those projects that sound simple and straightforward, it is not. It has been attempted many times before and never successfully.

I remember that one person tried this with a school canteen and got all the hardware working. However he then spent six months trying to find the right trigger level and failing. He reported that the signal levels he got did not correspond to the perceived level of loudness.

Ignoring for a moment the very real practical concerns raised by previous posters, there is guidance and example code for using the sensor here: http://sensorkit.en.joy-it.net/index.php?title=KY-038_Microphone_sound_sensor_module

hello

i am working on such a project. But i judo want to correlate the led with the perceived loudness not the DB.
And it is very hard to perceived the loudness with the analogic input. It varies very little even if the loudness varies a lot.