Double-clap light switch
Clap twice and the lights come on. Clap twice again to switch them off.
Shop by category
Shop all componentsThe Voice Recognition Module V3 stores up to 80 voice commands that you record yourself. It works offline, listens through a small microphone, and reports the number of the matching command over a serial link. An Arduino Uno reads that number and switches a relay for a lamp or fan. Because you train it with your own voice, it is more reliable for one speaker than for a crowd.
Keep the relay on low-voltage lamps and fans in this project.
Never wire mains around a bare relay module.
Tick anything you already have and the total updates.
Reads the module and drives the relay
Relay module for a low-voltage lamp or fan
SMPS supply, 12 V version, for a 12 V lamp or fan
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB powers the Uno and module. Keep the lamp on its own 12 V supply and switch only the + wire.
voice_switch.inoVerify & upload in Electrolark#include <SoftwareSerial.h>
#include "VoiceRecognitionV3.h"
VR myVR(2, 3); // module TX to D2, module RX to D3
const int RELAY = 7;
uint8_t buf[64];
void setup() {
Serial.begin(9600);
pinMode(RELAY, OUTPUT);
digitalWrite(RELAY, LOW);
myVR.begin(9600);
if (myVR.clear() == 0) Serial.println("Module ready");
myVR.load((uint8_t)0); // slot 0: "on"
myVR.load((uint8_t)1); // slot 1: "off"
}
void loop() {
int ret = myVR.recognize(buf, 50);
if (ret > 0) {
switch (buf[1]) { // buf[1] holds the slot number that matched
case 0: digitalWrite(RELAY, HIGH); Serial.println("on"); break;
case 1: digitalWrite(RELAY, LOW); Serial.println("off"); break;
}
}
}
Check the module's TX goes to D2 and RX to D3, and that the commands were loaded into the right slots.
Retrain the words so they sound different, and use longer words.
Speak close to the microphone and train in the same room you will use it.
It learns the person who trained it best. Others may need to train too.
No: it matches short words or phrases, up to about 1.3 seconds each.
Do not wire mains yourself. Use a relay in a proper enclosure, or a ready-made mains switch box.
6 parts: Uno R3 CH340G ATmega328p Development Board w/ Micro-USB, Voice Recognition Module V3, Raindrops Detection Sensor Module with 12V Relay Module – TTL Compatible, SMPS Power Supply, Metal Enclosure (5V / 12V / 24V), Solderless Breadboard and Dupont Jumper Wires (40 pcs). On this page you can tick the parts you already have and add only the rest to your cart.
It is a intermediate project and takes about 2 hours. The build on this page has 6 steps.
No. This page has the complete, tested code (voice_switch.ino).
About ₹3,010 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Training spoken commands on an offline module; Reading serial data from a module; Switching a relay safely.
Ideas that reuse this build: IR remote and motion light. They are listed under Take it further on this page.
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.
Learning project. Check every circuit and the datasheet of each part before you power it up.