กลับหน้าหลัก
views
How to Use KY-037 High Sensitivity Sound Sensor with Arduino
Last updated on

How to Use KY-037 High Sensitivity Sound Sensor with Arduino


How to Use KY-037 High Sensitivity Sound Sensor with Arduino

The KY-037 is a high-sensitivity sound detection module that provides both analog and digital outputs. It’s suitable for projects that need to measure sound levels or trigger actions when specific sound events occur.

Required Components

  • Arduino UNO R3
  • USB cable for uploading code
  • High Sensitivity Sound KY-037 sensor
  • Red LED 1 pcs
  • 220 Ohm resistor
  • Breadboard
  • Jumper wires

Wiring: Arduino + KY-037 + LED

Circuit diagram showing Arduino UNO connected to KY-037 sound sensor and LED on breadboard with pins 5V, GND, A5 and Pin 2 labeled
Arduino UNODeviceNotes
Pin 2LED (through 220Ω R)LED on/off control
5VKY-037 pin +Power supply
GNDKY-037 pin GCommon ground
A5KY-037 pin A0Analog read

Arduino Code: Read Sound from KY-037

const int soundPin = A5;    // Analog pin for sound
const int ledPin = 2;      // LED pin
const int threshold = 725; // Adjust based on your environment
int ledState = LOW;         // Initial LED state

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  pinMode(soundPin, INPUT);
}

void loop() {
  int soundValue = analogRead(soundPin);  // Read value 0-1023
  Serial.println(soundValue);                // Output to Serial Plotter


  // Toggle LED when sound exceeds threshold
  if (soundValue > threshold) {
    ledState = !ledState;                   // Toggle on/off
    digitalWrite(ledPin, ledState);
    delay(200);                              // Debounce to prevent rapid repeats
  }
}

Testing with Serial Plotter

  1. Upload the code to Arduino
  2. Open Serial Plotter via Tools → Serial Plotter (or Serial Monitor)
  3. Observe baseline reading when quiet — typically 0-50
  4. Clap your hands or make a sound near the sensor — value jumps up
  5. Adjust threshold in code based on your actual readings
Serial Plotter window showing graph of analog values from sound sensor, with peaks when sound is detected

Points to Customize

  • threshold — If LED turns on by itself when quiet, raise this value. If LED doesn’t respond to loud sounds, lower it.
  • delay(200) — Controls debounce. Smaller value = faster response but may flicker from a single sound event.
  • A0 pin — You can change to A0-A4 as needed. Update the pin number in code accordingly.
Comparison of Serial Monitor text output vs Serial Plotter graph display for KY-037 readings

Using Digital Output for Simpler Projects

If you only need to detect sound presence (HIGH/LOW), use D0 instead of analog:

const int digitalPin = 4;  // KY-037 D0 pin
const int ledPin = 2;

void setup() {
  Serial.begin(9600);
  pinMode(digitalPin, INPUT);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  int digitalValue = digitalRead(digitalPin);
  Serial.println(digitalValue);
  digitalWrite(ledPin, digitalValue);  // LED lights when sound detected
}

Note: D0 switches HIGH/LOW based on the trimpot setting on the module. Adjust the trimpot directly to set sensitivity for digital mode.

Reference Video

อยากทำโปรเจคแบบนี้?

รับทำโปรเจค Arduino / IoT จบงานไว ส่งงานครบ พร้อมสอน

If you need Arduino project service or urgent IoT development, see full service details on the home page

จ้างทำโปรเจคเลย

ความคิดเห็น