Microphone Sound Sensor(KY-038): 두 판 사이의 차이
잔글편집 요약 없음 |
잔글편집 요약 없음 |
||
| 1번째 줄: | 1번째 줄: | ||
{{#seo:|title= | {{#seo:|title=ArduWiki: Arduino Sound Detection Sensor (KY-038) Guide|title_mode=append|keywords=Arduino, Computer Science, Maker Education, Performance Assessment, Sound Detection Sensor (KY-038), Arduino Project, Capstone Project, Arduino Example Code|description=How to use the KY-038 sound detection sensor with Arduino (basic info, wiring, sample code). Ideal for CS and maker classes.}}[[파일:소리감지ky038대표이미지.jpg|center|class=coders100]] | ||
[[ | |||
This module detects the intensity of sound and changes the output voltage according to the ambient sound level, outputting it as an analog signal. | This module detects the intensity of sound and changes the output voltage according to the ambient sound level, outputting it as an analog signal. | ||
2025년 3월 27일 (목) 18:36 기준 최신판

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