
This project builds a clap-activated switch, relying on a sound sensor and a relay to control an electrical device, with simple code logic that tells a real clap apart from stray noise.
Components needed
An Arduino board, a sound sensor module (with an electret microphone and LM393 comparator), a relay module, and the device to be controlled.
Wiring it up
The module's digital output connects to an Arduino digital pin, while another digital pin controls the relay module's input, which switches the target electrical device on or off.
How it works
The electret microphone picks up ambient sounds within a 50Hz to 10kHz frequency range, and the LM393 comparator converts them into a digital signal that drops when a loud-enough sound is detected. Instead of relying on complex sound-pattern analysis, the code uses a simple timing mechanism: when the signal drops, the code checks whether at least 25 milliseconds have passed since the last recorded drop; this time threshold filters out electromagnetic noise or very brief transient vibrations, while still catching a real clap, which produces sustained enough acoustic pressure. With each valid clap, the code toggles the relay between on and off.
You can find sound sensors and relay modules at Juthour Tech.
Leave your comment