Вернуться на страницу библиотеки модулей
/*
KY-037 High Sensitivity Sound Sensor ("Big Sound") - Arduino example
Reads both module outputs: the digital output (DO) switches the Arduino's
on-board LED when sound crosses the potentiometer-set threshold, while the
analog output (AO) is printed to the Serial Monitor/Plotter as the raw level.
*/
int digitalPin = 7; // KY-037 digital interface (DO)
int analogPin = A0; // KY-037 analog interface (AO)
int ledPin = 13; // Arduino on-board LED pin
int digitalVal; // digital reading
int analogVal; // analog reading
void setup()
{
pinMode(digitalPin, INPUT);
pinMode(analogPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
// Read the digital interface
digitalVal = digitalRead(digitalPin);
if (digitalVal == HIGH)
{
digitalWrite(ledPin, HIGH); // Turn ON Arduino's LED
}
else
{
digitalWrite(ledPin, LOW); // Turn OFF Arduino's LED
}
// Read the analog interface
analogVal = analogRead(analogPin);
// Print the analog value to the serial monitor/plotter
Serial.println(analogVal);
}
Рекомендуемые ссылки:
Arduino KY-037 Sound Sensor (Big Sound) — Pinout, Wiring & Code
KY-037 Microphone sound sensor (high sensitivity) – SensorKit
KY-037 Microphone Sound Sensor with Arduino – HJWWalters
ky-037 high sensitivity sound detection module – Easyelecmodule
Подключение микрофонного модуля KY-038/KY-037 к Arduino