Clap Switch Circuit with Electret Mic, 555 Debounce and CD4013 Toggle

Clap once and the light turns on; clap again and it turns off. A clap switch combines four stages that appear in many larger systems: a sensor (microphone), an analog amplifier, a pulse shaper that turns a messy sound into one clean pulse, and a digital memory element that remembers the on or off state. Building it teaches you how analog and digital circuits hand signals to each other.

This design uses an electret microphone, a BC547 amplifier, an NE555 monostable for debouncing, and one half of a CD4013 dual D flip-flop wired to toggle. A second BC547 drives a 9 V relay.

Components Required

PartValue / TypeQuantity
Electret condenser mic2-pin, with bias resistor R1 4.7 kilo-ohm1
C1 (mic coupling)1 microfarad1
Q1, Q2BC5472
R2 (Q1 collector-base feedback)1 mega-ohm1
R3 (Q1 collector)10 kilo-ohm1
C2 (to 555 trigger)100 nanofarad1
VR1 + R4 (trigger bias)100 kilo-ohm preset (top) and 47 kilo-ohm (bottom)1 each
U1NE5551
R5, C3 (monostable)470 kilo-ohm, 1 microfarad1 each
C4 (555 pin 5)10 nanofarad1
U2CD4013B dual D flip-flop1
R6, C5 (power-on reset)100 kilo-ohm, 100 nanofarad1 each
R7 (Q2 base)10 kilo-ohm1
Relay, D2 (flyback diode)9 V coil, 1N40071 each
LED and resistor1 kilo-ohm1 each
Decoupling100 microfarad and 100 nanofarad1 each
Power9 V adapter (a battery runs down quickly with a relay)1

Circuit Explained Stage by Stage

Stage 1: Microphone and amplifier

An electret microphone contains a tiny FET and needs a DC bias, supplied by R1 from +9 V. The audio signal is coupled through C1 into Q1, a common-emitter amplifier biased by R2 from collector to base. This collector feedback bias is self-stabilising: if Q1 conducts more, its collector falls and reduces its own base current. With R2 at 1 mega-ohm and R3 at 10 kilo-ohm, the collector settles at a few volts for typical BC547 gains, leaving room to swing down on a loud sound.

Stage 2: 555 monostable debounce

A clap is a burst of many cycles lasting tens of milliseconds, plus echoes. Feeding that straight to a flip-flop would toggle it many times. Instead, Q1's collector is coupled through C2 to 555 pin 2. VR1 and R4 bias pin 2 just above one third of the supply, about 3.5 to 4 V. A loud clap swings pin 2 below 3 V, the 555 triggers and pin 3 goes high for T = 1.1 x 470 k x 1 uF, about 0.5 s. Further sound in that window is ignored, so each clap gives one clean pulse.

Stage 3: CD4013 toggle

In a D flip-flop, the Q output copies the D input on each rising clock edge. Connecting D1 (pin 5) to Q1-bar (pin 2) means D is always the opposite of Q, so every clock edge flips the output. The 555 output drives CLK1 (pin 3). SET1 (pin 6) is grounded. RESET1 (pin 4) has C5 to VDD and R6 to ground, giving a short high pulse at power-up so the switch always starts off.

Stage 4: Relay driver

Q1 output of the flip-flop (pin 1) drives Q2 through R7. Q2 switches the 9 V relay coil, with flyback diode D2 across it. An LED with its resistor in parallel with the coil shows the state.

CD4013 pinFunctionConnection
1Q1R7 to Q2 base
2Q1-barPin 5 (D1)
3CLK1555 pin 3
4RESET1C5 to VDD, R6 to GND
5D1Pin 2
6SET1GND
7VSSGND
8, 9, 10, 11Second flip-flop inputsAll to GND
12, 13Second flip-flop outputsNot connected
14VDD+9 V
MIC -> C1 -> Q1 (BC547 amp) -> C2 -> 555 pin 2 (biased near 4 V)
555 monostable (0.5 s) pin 3 -> 4013 CLK1
4013 Q1-bar -> D1  (toggle)
4013 Q1 -> R7 -> Q2 -> relay coil (D2 flyback) -> +9 V

How It Works

At power-up the reset pulse clears the flip-flop, so the relay is off. A clap is amplified by Q1, dips pin 2 of the 555, and produces a single 0.5 s pulse. The rising edge of that pulse clocks the CD4013, which toggles Q from low to high and turns the relay on. The next clap repeats the sequence and turns it off.

Assembly and Testing

  1. Build the microphone and Q1 stage. Measure Q1's collector; it should be between about 2 and 5 V. Adjust R2 if it is near 0 V or 9 V.
  2. Add the 555 stage with an LED on pin 3. Adjust VR1 until pin 2 sits at about 3.5 to 4 V, then clap: the LED should flash for half a second.
  3. Add the CD4013, tying every unused input to ground.
  4. Add Q2, the relay and D2. Clap and confirm the relay toggles once per clap.
  5. Fine-tune sensitivity with VR1: moving pin 2 closer to 3 V makes it more sensitive.

Troubleshooting

  • Relay toggles twice per clap: the monostable is too short. Increase C3 to 2.2 microfarad.
  • Relay switching triggers another toggle: the relay click or supply dip is reaching the amplifier. Add 100 microfarad decoupling and feed the mic and Q1 through a 100 ohm and 100 microfarad filter.
  • Responds to talking or music: pin 2 is biased too close to 3 V. Raise it slightly with VR1.
  • Random state at power-up: check the C5 and R6 reset network.
  • No response at all: check electret polarity; the pin connected to the case is ground.

Summary

The clap switch chains an amplifier, a 555 one-shot that converts each clap into one clean pulse, and a CD4013 wired as a toggle so successive pulses alternate the output. A transistor-driven relay makes the result useful for switching a low-voltage lamp.