Updated
The KY-037 is the kit's ear for the room. Its big microphone is the more sensitive of the kit's two sound sensors, and its comparator turns a clap into a pulse on a pin your board can count.
It's also one of the most misunderstood modules in the kit, because what comes out of it isn't a volume level. Here's what it really sends, how to set its trim pot so it ignores the room and catches the clap, and a clap switch that doesn't count one clap twice.

A microphone doesn't output loudness. It outputs the sound wave itself: a voltage that wobbles above and below a resting level, hundreds or thousands of times a second. On this board the trim pot sets that resting level, and the sound rides on top of it.
So when you plot A0 in a quiet room you see a nearly flat line, wherever the screw left it. Clap, and the line jumps for a moment, then settles. That's exactly what the walkthrough's Serial Plotter showed: background noise as a low ripple, and a spike for each clap.
D0 works from the same signal. The course's notes put the trip point at about 510: whenever A0 dips below it, D0 goes to 1 and the second LED flashes. A loud sound swings A0 across that line, so D0 pulses for as long as the sound lasts, which for a clap is a split second.
That's why the course's sketch checks every 5 ms, where the flame and temperature boards check every 150. A clap is over almost as soon as it starts, and a slow loop misses it.
| KY-037 pin | HERO Board | What it carries |
|---|---|---|
| A0 | A0 | The sound wave, on a resting level |
| G | GND | Ground |
| + | 5V | Power |
| D0 | Pin 8 | 1 while the sound crosses the trip point |
The walkthrough wires A0, G and + and watches the analog signal. The course's code also reads D0 on pin 8, so wire all four.
No library needed. The course's sketch lights the built-in LED while D0 is high:
const uint8_t KY_037_DIGITAL_IN = 8; // D0: 1 while the sound crosses the trip point
const uint8_t KY_037_ANALOG_IN = A0; // A0: the sound wave
void setup() {
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(KY_037_DIGITAL_IN, INPUT);
pinMode(KY_037_ANALOG_IN, INPUT);
}
void loop() {
int ky037_Dval = digitalRead(KY_037_DIGITAL_IN);
int ky037_Aval = analogRead(KY_037_ANALOG_IN);
if (ky037_Dval == HIGH) // louder than the set point
digitalWrite(LED_BUILTIN, HIGH);
else
digitalWrite(LED_BUILTIN, LOW);
delay(5); // check often: a clap is short
// Uncomment while you set the trim pot
// Serial.print("Digital Value: ");
// Serial.print(ky037_Dval);
// Serial.print(" | ");
// Serial.print("Analog value: ");
// Serial.println(ky037_Aval);
}The KY-038 runs this same sketch with different variable names. The LED flashes rather than staying on, because D0 only stays high while the sound lasts.
Serial.print lines, upload, and open the Serial Monitor at 9600 baud.The course's notes say the sensor is directional and works best with the sound straight in front of it, and suggest a speaker or a small motor as a steady test sound. The walkthrough found the same: when a clap was missed, it was usually down to where the microphone was aimed.
A clap switch is the classic sound build, and the walkthrough points at the next step: put a relay on it and clap your lights on. The trick is that one clap makes D0 pulse several times as the sound rings out, so a simple sketch toggles twice and ends up where it started. This one ignores D0 for 300 ms after each clap:
const uint8_t KY_037_DIGITAL_IN = 8; // D0
bool lightOn = false;
unsigned long lastClap = 0;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(KY_037_DIGITAL_IN, INPUT);
}
void loop() {
if (digitalRead(KY_037_DIGITAL_IN) == HIGH && millis() - lastClap > 300) {
lastClap = millis(); // ignore the rest of this clap
lightOn = !lightOn;
digitalWrite(LED_BUILTIN, lightOn ? HIGH : LOW);
}
}The loop has no delay(), so it never misses the start of a clap, and millis() keeps time for the 300 ms window. Once it works with the built-in LED, drive the kit's KY-019 relay from a free pin to switch something bigger, like a small fan. To ignore door slams and dropped books, ask for two claps: count the second only if it comes between about 0.2 and 0.8 seconds after the first.
The course's notes say the two work exactly the same way; the difference is the size and sensitivity of the microphone. The walkthroughs show what that means in practice. The KY-037's big microphone picked up claps well, while the small one on the KY-038 caught breath and close-up sounds and missed most claps; the instructor would pick the KY-037 for a clap sensor. Use the KY-037 for sounds in the room and the KY-038 for sounds right at the microphone.
The KY-037 walkthrough is lesson 29 of the SensorKit course, and the KY-038's is the next one. Every module in the 37-in-1 sensor kit covers the rest, and the analogRead article explains the 0 to 1023 reading.
37-in-1 Sensor Kit: Both sound sensors and 35 more modules in a latching case, with the free SensorKit course: 31 filmed walkthroughs and example code.
HERO Board: The Uno-compatible board the SensorKit walkthroughs are built around, with its USB cable.
Only the microphone. They share the same circuit and the same code. The KY-037's bigger microphone is more sensitive and better for claps across a room; the KY-038 suits sounds close to it.
No. Its output is the raw sound wave on a level set by the trim pot, not a calibrated loudness. You can compare louder and quieter, but not in decibels.
Its resting analog level is below the comparator's trip point of about 510. Turn the trim pot counter-clockwise in a quiet room until D0 reads 0.
Read D0, toggle a light when it goes high, and ignore D0 for about 300 ms afterwards so each clap counts once. The full sketch is on this page.