Introduction: Clap Activated Light Switch
This simple device allows you to make any common light switch clap activated.
Step 1: Acquire the Components
The components needed can be purchased most easily from Amazon
- 1 Arduino Uno with leads and power/sync cable
- 1 microphone
- 1 180 degrees hi torque micro servo
- 6 jumper leads
- 1 power bank
- 1 sheet of foem core
- 1 small sheet of thin metal or plastic
- 1 bread board
- A 1 inch diameter wooden dowel rod 2 inches long
- 1 heavy duty paper clip
Step 2: Program and Connect Arduino
With Arduino installed on your computer use the following code to program your arduino:
#include Servo
lightSwitch;
int sensor = 0;
boolean state = false;
int tolerance = 1000;
int counter = 0; int count = 3;
void setup() { Serial.begin(9600);
lightSwitch.attach(5); lightSwitch.write(0);}
void loop() { int raw = analogRead(sensor);
Serial.println(raw);
if (raw > tolerance){counter++;}
else{counter = 0;}
if (counter >= count)
{ if (state == false){ lightsOn();
state = true; }
else if (state == true)
{ lightsOff(); state = false; }
delay(2000); }
}
void lightsOn(){ lightSwitch.write(180); }
void lightsOff(){ lightSwitch.write(0); }
Connect the three leads going to the servo into the ground, "Vin" and #6 pins on the Arduino.
Plug the microphone into the breadboard and connect the 3 leads into another ground, "5v", and A0 pins on the Arduino.
Plug the power bank into the Arduino.
Step 3: Light Switch Attachment
Mark the metal or plastic plate and cut it to size.
Use a light switch to mark where to drill the hole for the 2 screws and and where to cut the slot for the switch and cut.
Use the piece of wood to make two legs that will hold the servo off the plate. I used hot glue to attach the servo to the wood.
Cut the foam core to build a box around the Arduino-microphone set up for protection.
Drill through the plate into the 2 wooden legs to connect the servo to the plate.
Mount the device to the light switch.
Straighten the paper clip and make a loop at one end to go around the switch. At the other end bend the clip so that it attaches the the servo arm.
Step 4: Try It Out!
With everything connected, clap and the switch should be flipped. In some cases you may have to clap more than once to activate it.

