Sound sensor value always reading 20

So I am using KY-308 sound sensor, when I output the sensitivity value I am always getting 20, I want to make it music reactive, so when I play music close to the microphone, 20 is still outputted as my sensitivity. I am hoping my sensitivity would change to somewhere between 500 and 550 when music is played, but it doesn't, can someone help me? Here is my code inside my loop function:

s=analogRead(A0);
 
  if((s>=535)&&(s<=540))//Change Sensitivity
  {
    leds[74]=CRGB (20, 135, 217);
    leds[75]=CRGB (20, 135, 217);
  }
  else if((s>=530)&&(s<=535))
   {
     leds[74]=CRGB (20, 217, 30);
    leds[75]=CRGB (20, 217, 30);
   }
  else
  {
     leds[74] = CRGB ( r,g,b);
     leds[75] = CRGB ( r,g,b);
  }
    for (int i = 0; i <= 73; i++) 
  {
     leds[i] = leds[i+1];
     leds[149-i] = leds[148-i];
     
  }
 FastLED.show();
 delay(30);

Post the entire code. To be sure, post the wiring as well.

The KY-038 has two signal outputs. A0 is an analog output take off the microphone element. D0 is a digital output that comes from a comparator indicating whether the analog signal is above a threshold set by the trim potentiometer (the boxy thing with a small screw head on the top).

If you're using the D0 digital output there is an LED on the board that indicates when it is above threshold. You can apply power to the board and adjust the trim pot (clockwise) until the light comes on and then back off slightly (counterclockwise) until the light just turns off to get the the most sensitive setting.

If you're using the A0 analog output then you should adjust the trim pot to get a mid-scale reading on the ADC, so nominally about 500.

Given that you report a value of "20", I presume you're using analogRead() as would be used for the A0 pin, but the value "20" sounds like what you'd see on the D0 pin.

The KY-038 doesn't have much analog gain so it requires a rather high sound volume to register much of a signal. It's intended as a "clap sensor" to detect a single large amplitude sound event. If you're really trying to capture analog sound then I've found the microphone boards based on the Max9814 to be a much much better choice.

DIY Music Reactive RGB LED Strip with Code| WS1228b | Using Arduino & Microphone Module - YouTube . Thanks for the reply, I followed this video exactly and tried to recreate everything he did, but sensitivity is where everything fell apart, if this sensor doesn't have much analogue gain, then the one in the video above is a different one?

Hi,
Welcome to the forum.

Can you please tell us your electronics, programming, arduino, hardware experience?

Do you get 20 if there is no sound as well?
That is, is the reading always 20?
How do you know you are getting a reading of 20?
What happens if you disconnect the sensor?

Thanks.. Tom.. :slight_smile:

Hi,
Sound unit used in YouTube.


And Fritzy, Ohhhhhhh :o

I think you have the D0 pin of the sound sensor connected to A0 pin of the Uno. It should be the A0 pin of the sound sensor to A0 of the Uno.

With verified, you can test the analogRead() of the sound sensor with a very simple sketch outputting to the serial plotter as follows. If this is outputting data, then adjust the trim pot (turn the screw) and the center point of the data should move. If I understand the code, it wants to be set to around 528.

You should be able to hum into the microphone and see something like a sine wave on the serial plotter screen.

void setup() {
  // initialize serial communication at 115200 bits per second:
  Serial.begin(115200);
}

void loop() {
  // read the input on analog pin 0:
  int sensorValue0 = analogRead(A0);
  Serial.println(sensorValue0) ;
  // delay(1) ;  
}

With that set up correctly, you can retry the full code for the lights.

Hi,
Can I suggest you forget that code for the while and look and do the process in this YouTube clip.

It has a narrator to tell you what is happening.
It goes back to basics to make sure your sensor is working.

You need to check each part of your project, the YouTube you have been watching unfortunately is hopeless when it comes to explaining what is going on.

Do this clip please to check that your sensor is working properly.

Thanks.. Tom... :slight_smile:

The ground and 5V seem to be reversed to me - worth a double check

Hi, so my electronics are W82S12B led strips, 5V power cable, an Uno, and sound sensor, and a few resistors

TomGeorge:
Hi,
Sound unit used in YouTube.


And Fritzy, Ohhhhhhh :o

TomGeorge:
Hi,
Sound unit used in YouTube.


And Fritzy, Ohhhhhhh :o

In your latest reply, you don't answer any of the important questions that have been asked, beginning with reply #4. Please go back and read those, try to answer them here.

Please post clear images of the actual hardware and wiring connections. It's extremely likely that you have made a connection error.

Also, in a technical field you can not get away with sloppy naming. It's a WS2812B, not a W82S12B or a WS1228B as you have annotated. Or maybe it isn't. How would I know, when parts often have only one digit or letter different for an entirely different part? I'm just making an educated guess. Don't force us to do that.

MrMark:
I think you have the D0 pin of the sound sensor connected to A0 pin of the Uno. It should be the A0 pin of the sound sensor to A0 of the Uno.

With verified, you can test the analogRead() of the sound sensor with a very simple sketch outputting to the serial plotter as follows. If this is outputting data, then adjust the trim pot (turn the screw) and the center point of the data should move. If I understand the code, it wants to be set to around 528.

You should be able to hum into the microphone and see something like a sine wave on the serial plotter screen.

void setup() {

// initialize serial communication at 115200 bits per second:
 Serial.begin(115200);
}

void loop() {
 // read the input on analog pin 0:
 int sensorValue0 = analogRead(A0);
 Serial.println(sensorValue0) ;
 // delay(1) ;  
}




With that set up correctly, you can retry the full code for the lights.

Hi, I have checked my connections again, it's connected to A0 of sound sensor and I am still getting 20.

Hi,
Please a drawn circuit diagram.
The sound sensor in the Fritzy is not the one you have in your hand.

Can you please tell us your electronics, programming, arduino, hardware experience?

Have you any code to JUST test the sound sensor?

Have you done as suggested in post#7?

Tom... :slight_smile:

TomGeorge:
Hi,
Please a drawn circuit diagram.
The sound sensor in the Fritzy is not the one you have in your hand.

Can you please tell us your electronics, programming, arduino, hardware experience?

Have you any code to JUST test the sound sensor?

Have you done as suggested in post#7?

Tom... :slight_smile:

My experience in electronics, programming, Arduino, and hardware are all intermediate.
Nope I haven't done just any code to test the sound sensor, I will check the link out in a bit and let you know.
https://www.amazon.ca/gp/product/B07DNWBG1D/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1. This is exactly what I got as my sound sensor. Is there a way to upload pictures from computer? Because all I see is url options, not uploading from a local device.

Here is a picture of my connections on the board 138329602_413721509920707_2305319244231550775_n.jpg - Google Drive

saildude:
The ground and 5V seem to be reversed to me - worth a double check

Just checked once again, and they were connected properly. Here is a link, to the drive for the connections 138329602_413721509920707_2305319244231550775_n.jpg - Google Drive

TomGeorge:
Hi,
Can I suggest you forget that code for the while and look and do the process in this YouTube clip.

It has a narrator to tell you what is happening.
It goes back to basics to make sure your sensor is working.

You need to check each part of your project, the YouTube you have been watching unfortunately is hopeless when it comes to explaining what is going on.

Do this clip please to check that your sensor is working properly.

https://www.youtube.com/watch?v=CbovaHqvdsM

Thanks.. Tom... :slight_smile:

TomGeorge:
Hi,
Can I suggest you forget that code for the while and look and do the process in this YouTube clip.

It has a narrator to tell you what is happening.
It goes back to basics to make sure your sensor is working.

You need to check each part of your project, the YouTube you have been watching unfortunately is hopeless when it comes to explaining what is going on.

Do this clip please to check that your sensor is working properly.

https://www.youtube.com/watch?v=CbovaHqvdsM

Thanks.. Tom... :slight_smile:

Thanks, I will try this out and see the outcome!

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