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:
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.
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?
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.
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.
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...
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.
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.
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.