Double-clap light switch
Clap twice and the lights come on. Clap twice again to switch them off.
Shop by category
Shop all componentsThe sound module has a microphone, an LM393 comparator and a small trimmer. When the sound is louder than the level you set, its DO pin goes LOW. The Arduino watches DO on D7 and lights the LED on D2 for a moment each time it sees a clap. Setting the trimmer is the real lesson: too sensitive and talking triggers it, too dull and claps are missed.
Every part for this build comes in the Geekobot Spark Kit box, a Geekobot exclusive, together with the parts for all 24 projects, from a first blinking LED to a smart fan and a reaction game. The wiring below is the kit's own wiring.
Tick anything you already have and the total updates.
The brain of every Spark Kit project
LM393 sound sensor with digital output
220 ohm resistor pack: limits the LED current
Sensor Shield v5.0 from the kit: every pin has its own G, V, S header, so modules plug in with female jumpers
Follow the colours: red is power, dark grey is ground, blue is a signal.
spark_kit_09_clap_detection.inoVerify & upload in Electrolark// Spark Kit 09: clap detection
int sound = 7; // DO of the sound sensor
int led = 2;
void setup() {
pinMode(sound, INPUT);
pinMode(led, OUTPUT);
}
void loop() {
if (digitalRead(sound) == LOW) { // most modules pull DO LOW on a loud sound
digitalWrite(led, HIGH);
delay(500); // keep it lit so you can see it
} else {
digitalWrite(led, LOW);
}
}
Use the kit's USB cable (some phone cables carry power only), install the CH340 driver on Windows if the port does not appear, and pick Tools > Board > Arduino Uno.
The trimmer is set too sensitive. Turn it until the module LED goes off in a quiet room.
Turn the trimmer the other way and clap closer. If your module goes HIGH on sound, change LOW to HIGH in the if.
Yes: flip the LED state on each clap and add a 300 ms pause so one clap does not count twice.
It sets the loudness at which DO switches, so you can tune it to your room.
Yes. It is one of the 24 projects in the Geekobot Spark Kit, and every part on the list comes in the kit box. You can also buy the parts one by one from the list above.
No. Every Spark Kit project is wired on the breadboard or the Sensor Shield with jumper wires.
8 parts: Uno R3 CH340G ATmega328p Compatible Development Board, Arduino USB-A to USB-B Data Cable for UNO/MEGA, Generic LM393 Sound Detection Sensor Module – Digital Output, Through-Hole LED Pack (Pack of 10), Carbon Film Resistor 1/4W 5% (Pack of 10), Solderless Breadboard, Dupont Jumper Wires (40 pcs) and Arduino Sensor Shield V5 Expansion Board. On this page you can tick the parts you already have and add only the rest to your cart.
It is a beginner project and takes about 30 minutes. The build on this page has 6 steps.
No. This page has the complete, tested code (spark_kit_09_clap_detection.ino).
About ₹484 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Digital sensors with an adjustable threshold; Event detection; Smart-home basics.
Clap twice and the lights come on. Clap twice again to switch them off.
Plays a friendly ding-dong whenever someone walks into the shop or room.
Beeps and flashes any message in Morse, or key your own by hand.
Turn a membrane keypad into a two-octave piano.
Lessons are free to read. Maker (₹499/month) and Pro add quizzes, worked problems and certificates, paid with your Geekobot account. See plans
Learning project. Check every circuit and the datasheet of each part before you power it up.