What it shows
A sound sensor turns the loud burst of a clap into a signal. The Arduino counts claps within a time window and toggles a relay, which switches a small lamp on and off.
The science
The module has a microphone, an amplifier and a comparator; its digital output goes high when the sound is louder than a level set by the on-board trimmer. The sketch records the time of each clap with millis(). Two claps between 150 ms and 700 ms apart count as a double clap and toggle the relay. Ignoring sounds for 100 ms after each clap stops one clap from counting twice because of echoes.
Materials
Cost: under Rs 1,500. Many items come from home or from waste; spare parts such as LEDs, motors and wire are in the store.
- An Arduino Uno or Nano
- A KY-038 or similar microphone sound sensor module with digital output
- A 5 V single-channel relay module
- A 5 V USB LED lamp (not a mains lamp) with a USB lead
- A power bank
- A breadboard and jumper wires
Safety
For this project: Use only a low-voltage 5 V USB lamp. Never connect a mains lamp or plug to this relay: leave that to a qualified electrician. Keep the relay contacts away from loose wires.
Never use mains electricity: power models with cells, batteries or a low-voltage adapter. Sharp and hot tools, flames and lab chemicals need an adult or your teacher beside you. Keep magnets, button cells and small parts away from young children, and wash your hands after making.
All the safety rulesStep by step
8 steps. Do them in order, and test each part before you go on to the next. Write what you notice in a notebook as you go.
Connect the sound module: VCC to 5 V, GND to GND and D0 to pin 2.
Connect the relay module: VCC to 5 V, GND to GND and IN to pin 7.
Cut the red wire of a USB lead, bring both cut ends to the relay COM and NO terminals, and insulate the joints with tape (ask an adult to help).
Plug the USB lead into the power bank and the lamp into the lead.
Set the trimmer on the sound module so that a normal voice does not trigger the output but a clap does; check with the on-board LED.
In the sketch, wait for the output to go high, record the time and ignore signals for 100 ms.
If a second clap arrives 150 to 700 ms after the first, toggle the relay state.
Test with single claps, a door slam and talking to find false triggers, and adjust the timing window.
What you should see
Two quick claps turn the 5 V lamp on, two more turn it off, and talking or single sounds are ignored.
Viva questions
A teacher or a judge will ask how it works. Try to answer each question before you open it, then compare.
1What does the sound module’s trimmer do?
It sets the loudness level that triggers the output.
2Why count two claps rather than one?
A single loud sound such as a door slam would turn the lamp on by mistake.
3Why wait 100 ms after a clap?
An echo or the clap’s long tail would count as a second clap.
4Why not use this circuit with mains lamps?
Mains voltage is dangerous and needs certified parts and an electrician.
Take it further
Add a second relay and use three claps for a USB fan.
Change one thing, measure what happens, and add a table or chart of your readings: that is what turns a model into your own investigation.
