As an Amazon Associate we earn from qualifying purchases.
A sound detector is one of the easiest ways to make a circuit react to the world around it. With an electret microphone and an LM358 op-amp, you can build a board that switches an LED or a relay when it hears a clap, a knock or a loud voice. It needs only a handful of cheap parts and runs from a small DC supply.
This guide explains how the circuit works, which parts you need, how the stages connect, and how to tune it so it triggers when you want it to and stays quiet when you don’t.
How the sound detector works
An electret microphone turns air pressure changes into a very small electrical signal, often only a few millivolts. That is too weak to drive anything directly, so the circuit has two jobs:
- Amplify the tiny microphone signal.
- Compare the amplified signal against a threshold and switch the output when the signal rises above it.
The LM358 suits this well because it contains two independent op-amps in one 8-pin package. One op-amp works as the amplifier and the other as the comparator, so a single chip handles the whole job.
Why use the LM358?
- It works from a single supply, so you don’t need a negative voltage rail.
- It accepts a wide supply range, so a 5 V supply from a USB port or an Arduino board works fine.
- It is cheap, easy to find and comes in a breadboard-friendly DIP package.
- Its inputs can go down to ground level, which is handy in single-supply audio circuits.
It is not a fast chip, and it is not a dedicated comparator. For detecting claps, knocks and speech-level sounds, that doesn’t matter. If you need very fast switching, a purpose-built comparator is a better choice.
Parts you need
- LM358 dual op-amp (DIP-8)
- Electret microphone (or a small microphone module)
- Resistors: about 10 kΩ for mic bias, 1 kΩ and 100 kΩ for the gain stage, two 10 kΩ for the mid-point reference, and a current-limiting resistor for the LED
- 10 kΩ potentiometer for sensitivity
- Capacitors: a coupling capacitor of around 1 µF to 10 µF, and a 10 µF to 100 µF supply decoupling capacitor
- LED, or a transistor and relay if you want to switch a larger load
- Breadboard, jumper wires and a 5 V supply
These values are common starting points rather than strict requirements. Adjust them to suit your microphone and the room you are working in.
Circuit stages explained
1. Microphone bias
An electret microphone has a built-in amplifier that needs a small bias current. Connect one terminal of the microphone to ground and the other to the supply through a resistor of a few kilohms, with 10 kΩ being a typical choice. The audio signal appears at the junction between the resistor and the microphone.
2. Coupling and mid-point reference
The microphone signal is AC, but the LM358 runs from a single supply. To handle this, create a reference voltage at half the supply using two equal resistors, such as 10 kΩ each, and bypass it with a capacitor. A coupling capacitor passes the audio signal from the microphone to the amplifier while blocking the DC bias.
3. Amplifier stage
Use the first op-amp as an inverting amplifier. Feed the signal through a 1 kΩ resistor to the inverting input (pin 2), place a 100 kΩ resistor between the output (pin 1) and that input, and connect the non-inverting input (pin 3) to the mid-point reference. The gain is roughly the feedback resistor divided by the input resistor, which here gives about 100. Raise or lower the feedback resistor to change it.
4. Comparator stage
The second op-amp acts as a comparator. Send the amplified signal to the non-inverting input (pin 5). Connect the inverting input (pin 6) to the wiper of the potentiometer, which sets the threshold voltage. When the signal rises above the threshold, the output (pin 7) goes high; when it falls back, the output goes low.
The LM358 output does not swing all the way to the supply voltage, so allow for that if you drive a transistor or a logic input from it.
5. Output
Connect an LED with a series resistor to pin 7 for a simple visual indicator. For a motor, buzzer or lamp, use the output to drive a transistor that switches the load, and add a flyback diode if the load is a relay coil.
Pin reference for the LM358
- Pin 8: positive supply
- Pin 4: ground
- Op-amp A: output pin 1, inverting input pin 2, non-inverting input pin 3
- Op-amp B: output pin 7, inverting input pin 6, non-inverting input pin 5
Setting the sensitivity
Start with the potentiometer set so the threshold sits a little above the resting level of the amplified signal. In a quiet room the LED should stay off. Then make a sound, such as a clap about a metre away, and slowly turn the potentiometer until the LED just lights on that sound.
If the output flickers, raise the threshold slightly or reduce the amplifier gain. If it never triggers, lower the threshold or increase the gain.
Making the output last longer
A clap is brief, so the LED may flash too quickly to notice. You can stretch the pulse by feeding the comparator output through a diode into a capacitor with a resistor to ground. The capacitor holds the charge for a moment after the sound ends. A transistor stage or a small microcontroller can also latch the output, which is useful for alarms.
Connecting it to a microcontroller
The output of the comparator can go straight to a digital input on an Arduino or similar board, provided it reaches the logic-high level your board expects. If you want to read the loudness instead of just a yes/no result, feed the amplifier output to an analog pin and use the placeholder