Hey new here and i'm currently undergoing a project for school. Have just bought sound sensors for a bigger project that i wish to start however want to make sure that the sound sensor is working and test the values that i can expect to be able to sense. There is something wrong with my code and will not print any values in the serial monitor. Any help would be greatly appreciated.
You normally connect a sound sensor to an analogue input and use analogRead to return a value.
Some that I have seen have an analog comparitor (LM393) that has a pot to set a threshold. They would connect to a digital port. Some have both analog and digital outputs. Remains to be seen what OP is working with.
Assuming your sensor has an analog output, run the [u]Analog Read Serial Example[/u] (with the sound sensor instead of the pot) to see what kind of readings you get. That will help you set the threshold.
Most Arduino compatible analog sound sensors are biased at 2.5V so they can read the negative half of the waveform and you'll read about 512 (half the ADC range) with silence. If you wish you can subtract-out the bias to get the true positive & negative readings.
Note that your readings will appear to be somewhat 'random" because you are [u]sampling a wave[/u] that has one positive peak, one negative peaks, and two zero-crossings per cycle, and you don't know where you are sampling it. And with the with the (short) delay in the program you may not "catch" the peak with short duration sounds (if you clap your hands, etc.).