0
\$\begingroup\$

schematic

simulate this circuit – Schematic created using CircuitLab

I am currently trying to test my sound sensor, before I hook it up to a bigger project.

I have changed the code from digital to analog and from analog back, but nothing seems to work.

It has 4 pins:

  • Vcc = hooked through breadboard to 5V power supply from my Arduino
  • GND = hooked through breadboard to GND
  • AO = hooked to A0
  • DO = not hooked to anything

The built in LED is flashing red, so there is power going through it. I do not know the model name, but it is a standard sound sensor with a blue relay on top and a "microphone" component at the end.

The values displayed by it are seemingly random, the values being:

  • controlSensor: 10-12
  • Soundsensor: 54

The controlSensor value will change randomly with each reboot and either switch between 10/11, regardless wheter or not I am yelling into it (i.e it will stay at 11 between comlpete silence and me yelling) or 11/12.

The soundSensor on the other hand is static at 54.

Anyone have any tips for making this work?

Thank you,

int soundSensor = A0;
int ledPin = 3;

void setup() {
  // put your setup code here, to run once:
   Serial.begin(9600);
   //Sensor Setup
   pinMode(soundSensor, INPUT);
   //LED Setup
   pinMode(ledPin, OUTPUT);
   digitalWrite(ledPin, LOW);
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(1000);
  Serial.println(soundSensor);

  int controlSensor = analogRead(soundSensor);
  if (controlSensor > 11){ //set the minimum value for activating the LED
    digitalWrite(ledPin, HIGH);
    delay(1000);
  } else {
    digitalWrite(ledPin, LOW);
  }
  Serial.println(controlSensor);
}
\$\endgroup\$
9
  • 2
    \$\begingroup\$ Post a schematic rather than a text description. There's a button on the editor toolbar for the built-in schematic tool. Use the Custom Component for the Arduino. Double click on a component to edit it. R, V & H for rotate, flip vertical and flip horizontal. "Save and Insert" when done. A photo may help too. \$\endgroup\$
    – Transistor
    Mar 8 '20 at 14:56
  • \$\begingroup\$ A link to the datasheet of the "sound sensor" would help. \$\endgroup\$
    – JRE
    Mar 8 '20 at 15:28
  • \$\begingroup\$ I can't find the model name for the sensor, but it is the one displayed here kookye.com/2015/03/20/sound-sensor-module-project \$\endgroup\$ Mar 8 '20 at 15:42
  • \$\begingroup\$ @Transistor I've never done schematics before, but I tried. Basicly, the sound sensor and the LED use the same GND, but the power supply to the LED comes from the board's digital pin 4. \$\endgroup\$ Mar 8 '20 at 15:50
  • \$\begingroup\$ I've tidied up your schematic for you and fixed the lists in your post. I think you need to learn the discipline to indent your code properly so I'm leaving that to you. Failure to do so will make it much more difficult for you or us to spot any errors. Hit the edit link again ... \$\endgroup\$
    – Transistor
    Mar 8 '20 at 16:07
2
\$\begingroup\$

Here's the circuit from your "sound sensor:"

enter image description here

Source.

Your so-called "blue relay" is a potentiometer. You use the potentiometer to set the sound level at which the D0 output changes state.

A0 will be greatly influenced by the setting of the potentiometer.

Your code is reading the audio level once per second. Audio changes thousands of times per second.

Whatever you are reading from the sound sensor is in no way a good represenation of the sound in the room. It'll be more related to the potentiometer setting than to the audio.

Adjust the potentiometer so that the LED lights up or flickers when you make loud noises. Connect D0 to a digital input on the Arduino and read it in a loop without a delay, and change your LED state depending on whether the digital input is high or low.


The circuit isn't really an audio amplifier. The LM393 is a comparator - it delivers an on/off signal indicating whether its input is above or below a selected level.

\$\endgroup\$
2
  • \$\begingroup\$ Thank you for your suggestion, I tried spooling the potentiometer towards the 1 marking on the side of it. The numbers I recieve are still apparently random and are now static. I tried spooling, so it would be between 15 and 14 (changing randomly) but even then there was no connection between me clapping my hands and the light bulb flashing. Also, in regards to the digital output. I have set it so that sensorValueDig = A1, and the output value is now 55, regardless of how I spool the potentiometer. Before, it was at digitalpin 2, and the value was a static 2 in monitor. \$\endgroup\$ Mar 8 '20 at 17:00
  • \$\begingroup\$ The module has an LED. Adjust the potentiometer, and watch the LED on the module while making noises. If that LED never blinks, then the module is broken. \$\endgroup\$
    – JRE
    Mar 8 '20 at 17:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.