3

I am having trouble with the arduino sound sensor and LEDs. I keep on getting the value of 0 in my serial monitor, the same thing happens with another sound sensor that I have. I am currently trying to make it light up the LEDs based on the sound but with the serial monitor reading 0 it will not activate the code. There should be a picture attached. The lights on the sound sensor is lighting up so I know the GND and 5V is working. Since it is hard to tell I am using 330 ohm resisters. I got the sound sensor from an elegoo starter kit, so I know it might be cheap. The picture is in the link at the end. Thank you.

     int MicPin = A0;
     int MicValue1 = 0;
     int MicValue2 = 0;

     int led1 = 2;
     int led2 = 4;
     int led3 = 6;
     int led4 = 8;

     void setup() {
     pinMode(led1, OUTPUT);
     pinMode(led2, OUTPUT);
     pinMode(led3, OUTPUT);
     pinMode(led4, OUTPUT);
     pinMode(MicPin, OUTPUT);
     Serial.begin(9600);
      }

     void loop() {
     MicValue1 = analogRead(MicPin);
     Serial.println(MicValue1);
     delay(1);
     MicValue2 = analogRead(MicPin);
     Serial.println(MicValue2);

     if (MicValue1 - MicValue2 > 1) {
     digitalWrite(led1, HIGH);
     delay(2000);
     }
     else {
     digitalWrite(led1, LOW);
     }
    } 

enter image description here

1 Answers1

1

I assume that you have a simple analog-output sensor module that provides 10bit analog values based on the environment volume level. If this assumption is correct, you wired all pins correctly and the received value is always out of range or at the maximum, you maybe had to integrate a resistor to get a valid value. Try a small resistor and increase the resistance until you receive suitable values. Maybe the documentation of your module provides further information.

There is a small rotating knob connected to the sensor on which we need to rotate to adjust particular resistance values, you can see different values in serial monitor out.

Useful link

Mathews Sunny
  • 1,796
  • 7
  • 21
  • 31