Control an AC Bulb with a Hand Clap, Voice, or Sound
In this tutorial, you will learn how to control an AC bulb using a sound module that detects claps or voice commands. By using this setup, you can easily turn the light on or off based on sound input. This project utilizes a relay to switch the power to the AC bulb, allowing for safe control of high voltage devices with simple sound commands. The outcome is a functional light that responds to your voice or claps, making it a fun and practical project. The module is also called KY-037 voice detection or sound detection module.

Before diving into the specifics, it's essential to understand the components involved in this project. The sound module detects audio signals and sends a corresponding signal to the Arduino. The Arduino processes this signal and controls a relay, which in turn powers the AC bulb. This system can respond to various sound levels, allowing for flexibility in how you choose to activate the light (in video at 00:30).
Hardware Explained
For this build, you will need the following components:
- Arduino Board: Acts as the central controller that processes input from the sound module and controls the relay.
- Sound Module: This module detects sound inputs (like claps or voice commands) and outputs a signal to the Arduino. It typically includes a microphone and an op-amp to amplify the sound.
- Relay Module: A relay allows you to control higher voltage devices like an AC bulb. It acts as a switch that can be turned on or off by the Arduino.
- AC Bulb: The light source you will be controlling. Ensure it is connected safely through the relay.
The sound module works by converting sound waves into electrical signals that the Arduino can read. The relay module uses a low-voltage input from the Arduino to switch the high-voltage AC current on or off, making it a critical component for safe operation.
Datasheet Details
| Manufacturer | Generic |
|---|---|
| Part number | Sound Detection Module |
| Logic/IO voltage | 5 V |
| Supply voltage | 5 V |
| Output current (per channel) | 20 mA |
| Peak current (per channel) | 50 mA |
| PWM frequency guidance | N/A |
| Input logic thresholds | TTL compatible |
| Voltage drop / RDS(on) / saturation | 0.1 V max |
| Thermal limits | 85 °C |
| Package | Module |
| Notes / variants | Commonly used in various DIY projects |
- Ensure proper heat dissipation for the relay module.
- Use decoupling capacitors near the power supply to stabilize voltage.
- Keep the wiring organized to prevent accidental short-circuits.
- Be cautious of the AC voltage; ensure all connections are secure.
- Adjust the sensitivity of the sound module to your environment.
Wiring Instructions

Begin by connecting the sound module to the Arduino. Connect the DO (data output) pin of the sound module to pin 2 on the Arduino. The VCC pin should be connected to the 5V output on the Arduino, and the GND pin should be connected to one of the Arduino's ground pins.
Next, wire the relay module. Connect the VCC pin of the relay to the 5V pin on the Arduino and the GND pin to ground. The input pin of the relay should be connected to pin 10 on the Arduino. Finally, connect the AC bulb to the common and normally open terminals of the relay, ensuring that the circuit is properly isolated from any exposed contacts.
Code Examples & Walkthrough
The following code excerpt shows how to set up the pins and read the sound input:
int SOUND = 2; // connect output to Sound module DO
int relayPin = 10; // Connected to relay (LED)
void setup() {
Serial.begin(9600);
pinMode(SOUND, INPUT_PULLUP);
pinMode(relayPin, OUTPUT);
}
In this setup, the sound module's output is connected to pin 2, which is configured as an input with a pull-up resistor. The relay pin is set as an output to control the relay.

Next, the main loop checks for sound input and controls the relay based on the detected sound:
void loop() {
val = digitalRead(SOUND);
if(val == HIGH && lightON == LOW){
heard = 1 - heard;
delay(100);
}
lightON = val;
if(heard == HIGH){
Serial.println("Light ON");
digitalWrite(relayPin, LOW);
}else{
Serial.println("Light OFF");
digitalWrite(relayPin, HIGH);
}
delay(100);
}
This loop continuously reads the sound input. If a sound is detected (when val is HIGH), it toggles the state of the light. The heard variable tracks whether a sound has been detected, and the relay is activated accordingly.
Demonstration / What to Expect
Once everything is wired and the code is uploaded, you can test the functionality by clapping or speaking near the sound module. The light should turn on with the first clap or sound and turn off with the next. Be mindful of the distance and volume of your voice, as these can affect the detection (in video at 05:00).
Common pitfalls include incorrect wiring, especially with the relay, which can lead to unsafe conditions. Ensure that the relay is properly connected and that the AC bulb is correctly wired to avoid any electrical hazards.
Video Timestamps
- 00:00 - Introduction to the project
- 01:00 - Overview of components used
- 02:30 - Wiring instructions
- 04:15 - Code walkthrough
- 05:00 - Demonstration of functionality
Images
Things you might need
-
Amazon
-
eBayISD1820 Voice Recorder from eBayebay.us
-
AliExpressPurchase this item from AliExpresss.click.aliexpress.com
Resources & references
No resources yet.
Files📁
Fritzing File
-
Sound Detection Module Module (KY-037)
application/zip0.03 MB