Teach Your Kid Electronics

Advanced · Project 11

Clap-On Light

Clap once and the light turns on; clap again and it turns off. A microphone, an amplifier chip, a comparator and a flip-flop work together in a chain.

Build this only with an adult present. Before you start, read our safety notice and disclaimer.

Advanced⏱ About 60 min

🧰 What you need

  • 1×Full-size breadboardThe big brother of the half-size board: twice as long, with room for several chips.
  • 1×3×AA battery holder with wire leadsHolds three AA batteries in a row and gives you a red (+) and black (−) wire.
  • 3×AA batteryA regular household battery. Each one gives 1.5 volts.
  • 1×Electret microphone capsuleA tiny round microphone with two legs. The leg joined to its metal case is −.
  • 1×LM358 dual op-ampTwo amplifiers in one chip. With two resistors it can make a tiny signal 100 times bigger.
  • 1×LM393 comparator chipCompares two voltages and switches its output depending on which is higher. Has two comparators inside.
  • 1×74HC74 flip-flop chipTwo D flip-flops: tiny memories that each store one bit (on or off).
  • 1×10 kΩ potentiometer (knob)A resistor you can change by turning a knob. Three legs: two ends and a middle "wiper".
  • 3×100 kΩ resistor — brown, black, yellow, goldColors: brown, black, yellow, gold.
  • 1×47 kΩ resistor — yellow, violet, orange, goldColors: yellow, violet, orange, gold.
  • 1×33 kΩ resistor — orange, orange, orange, goldColors: orange, orange, orange, gold.
  • 1×22 kΩ resistor — red, red, orange, goldColors: red, red, orange, gold.
  • 2×10 kΩ resistor — brown, black, orange, goldColors: brown, black, orange, gold.
  • 1×1 kΩ resistor — brown, black, red, goldColors: brown, black, red, gold.
  • 1×220 Ω resistor — red, red, brown, goldOur go-to LED resistor. Colors: red, red, brown, gold.
  • 2×1 µF capacitorA small can-shaped capacitor. The striped leg is −.
  • 2×10 µF capacitor (can-shaped)A small can-shaped capacitor. The striped leg is −.
  • 1×5 mm LED (any color)A tiny light that only lets current flow one way. The long leg is +.
  • 30×Jumper wireA short wire with stiff ends that push into the breadboard.

✨ The finished project

↔ Big board! Scroll sideways to see all of it.

A clap-on light: a microphone, an LM358 amplifier, an LM393 comparator and a 74HC74 flip-flop that flips the light on and off with each clap ++−−++−−aabbccddeeffgghhiijj115510101515202025253030353540404545505055556060 10kΩ 1µF 10µF 1µF 10µF LM358 LM393 74HC74 +− 10 kΩ 100 kΩ 100 kΩ 100 kΩ 1 kΩ 33 kΩ 22 kΩ 47 kΩ 10 kΩ 220 Ω +− AAAAAA3 × AA = 4.5 V+−
A clap-on light: a microphone, an LM358 amplifier, an LM393 comparator and a 74HC74 flip-flop that flips the light on and off with each clap ++−−++−−aabbccddeeffgghhiijj115510101515202025253030353540404545505055556060 10kΩ 1µF 10µF 1µF 10µF LM358 LM393 74HC74 +− 10 kΩ 100 kΩ 100 kΩ 100 kΩ 1 kΩ 33 kΩ 22 kΩ 47 kΩ 10 kΩ 220 Ω +− AAAAAA3 × AA = 4.5 V+−
Schematic: A clap-on light: a microphone, an LM358 amplifier, an LM393 comparator and a 74HC74 flip-flop that flips the light on and off with each clap + IN1+3IN1-2IN2+5IN2-6OUT11OUT27VCC8GND4LM358U1 + + IN1+3IN1-2IN2+5IN2-6OUT11OUT27VCC8GND4LM393U2 + 1D21CLK31PRE41CLR12D122CLK112PRE102CLR131Q51Q̄62Q92Q̄8VCC14GND774HC74U3 + +4.5V +4.5V +4.5V +4.5V +4.5V +4.5V +4.5V +4.5V +4.5V +4.5V 4.5 V microphone 10 kΩ 1 µF 100 kΩ 100 kΩ 100 kΩ 1 kΩ 10 µF sensitivity 33 kΩ 22 kΩ 47 kΩ 1 µF 10 kΩ 10 µF 220 Ω yellow LED
The finished build. This picture is generated from the circuit itself and checked by computer, so every leg is in the right hole.

🔣 New schematic symbols

This project’s schematic has some symbols you haven’t seen before. Here’s what they mean.

  • Microphone

    A circle with a thick line on one side, like the face of a microphone. Sound wobbles its electricity a tiny bit; the + leg needs a resistor to battery + to power it.

Clap your hands: the light comes on. Clap again: it goes off. No buttons at all! This is the most “grown-up” circuit so far, but each part of it is something you’ve already met. The trick is to think of it as a chain of four jobs, each passing its result to the next:

listen (microphone) → make it bigger (amplifier) → decide (comparator) → remember (flip-flop) → light

1. Listen: the microphone

An electret microphone is a tiny metal can with a thin, springy sheet inside. Sound waves wobble the sheet, and that wobbles the electricity flowing through it, by just a few hundredths of a volt. It needs power, which it gets through a 10 kΩ resistor from +. Its − leg is the one joined to its metal case (look for the thin metal tracks).

2. Make it bigger: the amplifier

A few hundredths of a volt is far too small to decide anything. An amplifier makes a signal bigger. Ours is an op-amp: the LM358 chip has two of them inside (we use the second one, “half 2”). An op-amp on its own is wildly powerful, so two resistors tame it: 100 kΩ and 1 kΩ make it exactly about 100 times bigger. That’s called its gain.

LM3581OUT12IN1-3IN1+4GND5IN2+6IN2-7OUT28VCC
  • Pin 2 · IN1- — unused half: joined to OUT1
  • Pin 3 · IN1+ — unused half: held at −
  • Pin 4 · GND — battery −
  • Pin 5 · IN2+ — the sound goes in here
  • Pin 6 · IN2- — the gain resistors (100 kΩ and 1 kΩ)
  • Pin 7 · OUT2 — the amplified sound comes out
  • Pin 8 · VCC — battery +

Two more tricks:

  • The 1 µF capacitor in front lets the wobble through but blocks the steady voltage. (A capacitor can’t pass a steady current, only changes.)
  • Two 100 kΩ resistors hold the amplifier’s input at half the battery voltage. Then the sound can wobble it both up and down.

3. Decide: the comparator

Is that a clap, or just someone talking? The LM393 comparator from the Fever Alarm compares the amplified sound with a level you set with a knob. When the sound goes above it, the comparator’s output pulls low.

A clap’s sound wobbles hundreds of times, so the output would flicker hundreds of times. A 47 kΩ resistor and a 1 µF capacitor smooth that into one long pulse. The comparator empties the capacitor in an instant, but the resistor only refills it slowly, so the pulse stays low until a moment after the clap ends.

4. Remember: the flip-flop

The 74HC74 flip-flop from Flip-Flop Memory is wired as a toggle: its Q̄ output goes back to its own D input. Every time the clock rises, it saves the opposite of what it remembered, so it flips: off, on, off, on. The clock is our clap pulse: it rises as each clap ends.

Build it

Build it one job at a time, left to right. Chips go in with their notch on the left.

  1. Rail bridges: red T+47 → B+47 (bottom red + rail, column 47), black T-46 → B-46 (bottom blue − rail, column 46).

  2. Microphone: + leg d16, − leg (the one joined to the case) d17. Black a17 → T-17 (top blue − rail, column 17). 10 kΩ b16 → T+16 (top red + rail, column 16).

  3. LM358: pin 1 in f9. Red a9 → T+9 (top red + rail, column 9); black j12 → B-11 (bottom blue − rail, column 11). Unused half: blue g9 → g10, black h11 → h12.

  4. Into the amplifier: 1 µF capacitor + c12, − c16. 100 kΩ a12 → T+11 (top red + rail, column 11) and 100 kΩ b12 → T-13 (top blue − rail, column 13).

  5. Gain: 100 kΩ b11 → b8, blue c8 → c10. 1 kΩ d11 → d7, 10 µF capacitor + a7, − T-7 (top blue − rail, column 7).

  6. Amplified sound out: orange e8 → f8 over the gap, then i8 → i23.

  7. LM393: pin 1 in f22. Red a22 → T+22 (top red + rail, column 22); black j25 → B-25 (bottom blue − rail, column 25); black a25 → T-25 (top blue − rail, column 25) and a24 → T-23 (top blue − rail, column 23) (the unused half).

  8. Sensitivity knob: legs in h27, h28, h29. 33 kΩ j27 → B-26 (bottom blue − rail, column 26); 22 kΩ j29 → B+31 (bottom red + rail, column 31). Green i28 → i24.

  9. Pulse smoother: 47 kΩ j22 → B+23 (bottom red + rail, column 23); 1 µF capacitor + h22, − B-19 (bottom blue − rail, column 19). Yellow g22 → g36 (1CLK).

  10. 74HC74: pin 1 in f34. Red a34 → T+34 (top red + rail, column 34); black j40 → B-40 (bottom blue − rail, column 40). Toggle: white h35 (1D) → h39 (1Q̄). Red j37 → B+37 (bottom red + rail, column 37). Unused flip-flop 2: red a35 → T+35 (top red + rail, column 35), black a36 → T-37 (top blue − rail, column 37), black a37 → T-38 (top blue − rail, column 38), red a38 → T+38 (top red + rail, column 38).

  11. Power-on reset: 10 kΩ j34 → B+35 (bottom red + rail, column 35); 10 µF capacitor + i34, − B-32 (bottom blue − rail, column 32).

  12. Light: 220 Ω i38 (1Q) → i43. LED long leg h43, short leg h44. Black j44 → B-44 (bottom blue − rail, column 44).

  13. Power: 3×AA red into T+1, black into T-2. The light starts off. Clap! 👏

The build check simulated real claps: a sound wobbling 500 times a second for a twentieth of a second. It checked the light turns on, stays on, turns off at the next clap, and on again at the third.

Set the sensitivity

Turn the knob so that one sharp clap about an arm’s length away switches the light, but talking doesn’t. Turned one way it’s very sensitive (it might react to a door closing); the other way it needs a loud clap right next to it.

Not working?

  • Nothing happens when you clap? Turn the knob toward “sensitive”, and clap closer. Check the microphone’s − leg (joined to the case) goes to −.
  • The light flips by itself? It’s too sensitive: turn the knob the other way.
  • It flips twice on one clap? Swap the 1 µF smoothing capacitor for a bigger one (try 2.2 µF).
  • Light never comes on? Check the white toggle wire (1D to 1Q̄), and the flip-flop’s power wires.

Try it!