DIY Electronics
— Building circuits, programming microcontrollers, and making things blinkGPIO expander (MCP23017) for when you run out of pins
Building a DIY Clap Switch
A clap-activated switch is a classic project that teaches analog comparator design and debouncing. Here's a clean implementation.
The microphone output is AC-coupled through a capacitor and amplified by a common-emitter transistor stage to about 2V peak-to-peak. The amplified signal feeds an LM393 comparator with a threshold set to trigger on loud sounds (handclap, finger snap) but not on normal conversation.
The comparator output triggers a 555 timer in monostable mode for a 100ms pulse — this debounces the clap burst. A flip-flop (one half of a 74HC74) toggles the relay state. The second clap toggles it back. The key calibration is the comparator threshold: too low and it triggers on speech; too high and a clap doesn't register. A trim potentiometer for adjustment is worth including.