Circuits / Sensors
Arduino UNO: clap switch with a KY-037 sound module
A clap is any change of DO from its resting level, whichever way the board moves it and however short the pulse. The sketch takes the rest level from 100 readings, polls without waiting and accepts the next clap only when DO is back at rest and 200 ms have passed.

Tap a part to see its voltages and currents. It is a model, not a measurement.
What do you need?
- Development board Arduino UNOAliExpress Amazon
- Sensor module (LM393) KY-037AliExpress Amazon
- Resistor 220 ΩAliExpress Amazon
- Green LEDAliExpress Amazon
- Jumper wires × 6AliExpress Amazon
- BreadboardAliExpress Amazon
The AliExpress links are affiliate links: if you buy through them ohmio.dev gets a commission, at no extra cost to you. Affiliate links
This page is a guide: the numbers come from a simulation, and real parts vary. Check your parts before you power the circuit. Safety and responsibility
How does an Arduino toggle an LED with a clap?
The KY-037 module has a microphone and a comparator. A clap makes a brief peak in the microphone's signal, and when the peak passes the trimmer's reference the comparator's output, DO, changes. In the model DO sits at 4.99 V in a quiet room and falls to 0.20 V from about 98 dB. Which way DO moves on a real board is not confirmed, and its pulses can be very short, so the program depends on neither. In setup() it takes the level most of 100 readings had as rest. In loop(), with no delay(), any change from rest toggles the LED on D13 through R1 (220 Ω): in the model it takes 11.1 mA, and a second clap turns it off. The next clap counts only once DO is back at rest and 200 ms have passed. The trimmer must sit within millivolts of the microphone's resting level: turn it slowly and test with a real clap.
Values from the Protoboard ISO simulation: a model, not a bench measurement.
Hear about the next circuit
One email when a new circuit is out, about twice a month. Nothing else.