Microphone Sound Sensor(KY-038)
This module detects the intensity of sound and changes the output voltage according to the ambient sound level, outputting it as an analog signal.
It is similar to the KY-037 model.
Specifications
- Operating Voltage [V]: 3.3 ~ 5
- Frequency Range [Hz]: 50 ~ 20K
Example Usage Hardware
- Arduino board
- Jumper cables
- KY-038 Sound Detection Sensor
Connection
Although the digital pin is not used in this example, please refer to it as a connection example.
When using the KY-038 module digitally, supply power to the module in a quiet environment and then adjust the sensitivity by turning the variable resistor.
Arduino Uno | KY-038 |
5V | + |
GND | G |
D8 | DO |
A0 | AO |
Example Code
This example turns on the internal LED (pin 13) of the Arduino when sound is detected and then turns it off after a certain period.
int analogPin = A0;
int ledPin = 13;
int analogVal = 0;
long int past_time = 0;
int past_analogVal = 0;
void setup() {
pinMode(analogPin, INPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);
Serial.begin(9600);
}
void loop() {
analogVal = analogRead(analogPin);
if (millis() - past_time > 1000) {
if (abs(past_analogVal - analogVal) > 3) {
digitalWrite(ledPin, !digitalRead(ledPin));
past_analogVal = analogVal;
past_time = millis();
}
}
delay(10);
}
Execution Result