Sound-Sensor is not working

Hello

I am a newbie.

I am trying to get a Sound-Sensor to work. But with no luck. What could I be missing?

The sound sensor example which I am inspired from could be accessed from the link:

Below is my code:

const int soundPin = 7;

int soundVal;

void setup ()
{
  pinMode (soundPin, INPUT);
  Serial.begin(9600); // open the serial port at 9600 bps:
  }
 
void loop ()
{
  soundVal = digitalRead(soundPin);
  Serial.print("Sound Value is: " +soundVal);
  
}

The output for soundVal is nothing. I am getting output something like this:

Sound Value is:
Sound Value is:
Sound Value is:
...

I tried working with a different sound-sensor, but still no luck.

Try;

int sumsoundVal = soundVal +sumsoundVal;
Serial.print("Sound Value is:  " );
Serial.println(somsoundVal);

In the digitalRead, the result can only be 0 or 1.
Tom... :smiley: :+1: :coffee: :australia:

Thanks Tom. Now it prints.

My next problem is, it gives output "0" irrespective of whether i make sound or not (and never "1").

15:37:34.097 -> Sound Value is: 0
15:37:34.097 -> Sound Value is: 0
15:37:34.097 -> Sound Value is: 0
15:37:34.117 -> Sound Value is: 0
15:37:34.150 -> Sound Value is: 0

Like @TomGeorge pointed out, the output is digital and so will be HIGH (no sound) or LOW (sound).

Try this code:

const int soundPin = 7;

int soundVal;

void setup ()
{
   pinMode (soundPin, INPUT);
   Serial.begin(9600); // open the serial port at 9600 bps:
}

void loop ()
{
   soundVal = digitalRead(soundPin);
   if (soundVal == LOW)
   {
      Serial.print("Sound detected");
   }
}

You may need to adjust the sensitivity (blue pot) to get an output.

There is more example code on the page that you linked.

Sorry, Tom. I meant to reply to the OP.

Good Point. Let me adjust the sensitivity. And then try again. Thanks.

Hi,
What sort of noise are you making to try and trigger it?

Try clapping over the microphone.

Tom... :smiley: :+1: :coffee: :australia:

Thanks. I am trying to trigger it when I Clap.

Now, I am getting the output as:
15:58:33.355 -> Sound detected
15:58:33.355 -> Sound NOT detected
15:58:33.389 -> Sound NOT detected
15:58:33.422 -> Sound NOT detected
15:58:33.422 -> Sound detected
15:58:33.455 -> Sound NOT detected
15:58:33.455 -> Sound NOT detected

I think the soundsensor is very sensitive as of now. It is picking up background noise. I guess I will have to adjust the sensitivity and try again.

How to get Arduino to work with 2 sound-sensor-modules?
(I can get it to work with 1 sound-sensor-module)

const int soundPinRight = 7;
const int soundPinLeft = 8;

int soundValRight;
int soundValLeft;

void setup ()
{
   pinMode (soundPinRight, INPUT);
   pinMode (soundPinLeft, INPUT);
   Serial.begin(9600); // open the serial port at 9600 bps:
}

void loop ()
{
   soundValRight = digitalRead(soundPinRight);
   soundValLeft = digitalRead(soundPinLeft);
   
   if (soundValRight == LOW)
   {
      Serial.println("Sound Right detected");
   }

      if (soundValLeft == LOW)
   {
      Serial.println("Sound Left detected");
   }
   
 }

There is only one single port for '5V' so I connected it to the breadboard. And then connected the breadboard to the 2 sensors. The problem is sensitivity does not work anymore on the sound-sensors.

What am I missing?

Have you commoned up the Ov connections from the sensors and the Arduino 0v ?

Go back to one sensor on the breadboard , get that running , then add the second - that will help find any faulty wiring .

Even if I connect 1 sensor-module to the breadboard, it doesn't work. The sensor-module loses it's sensitivity.

If I connect the power directly to the sensor-module, it works.

sorry works now. i made a mistake in connectivity of the power wire. sorry for the trouble. thanks.

It is taking sound to travel 15cms in 66ms. Would that be right? (Temp is around 30 degrees Celsius out here)

https://physics.stackexchange.com/questions/732144/experiment-with-sound

It’s about 350m/s at 30c

So nope , more like .4mS

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.