Project tutorial
The Clapper!

The Clapper!

Use a Electret Mic to turn a light on and off.

  • 12,437 views
  • 4 comments
  • 23 respects

Components and supplies

About this project

Intro:

Saw an old YouTube video about the Clapper, "Clap on, Clap off..." and thought "That would be a fun little project".   So here is a quick and easy project that utilizes a electret mic, relay, and an Uno.  When you clap your hands (or any loud noise) it will toggle a relay.  In my case have a extension cord connected to the relay which you can plug a light or some other AC appliance.

PLEASE READ: Electricity can be dangerous.  Please use caution as I am not responsible if you hurt yourself.

Step 0 - Chop up an Extension Cord

  • Take an extension cord make sure it isn't plugged in and split the wires
  • Cut one of the wires and strip back the insulation to expose the bare wire
  • Solder the wires ends to keep the strands from going everywhere

Step 1 - Connect the Parts

Plug mic into breadboard and connect pins to Uno.  The mic I am using can use 3.3V or 5V

OUT --> Pin 6 on Uno

GND --> Ground rail on breadboard

VCC --> +5V rail on breadboard

Plug Relay into breadboard and connect pin to Uno.  I am using a 4 channel relay buy you can buy single channel relays if desired.

GND --> Ground rail on breadboard

VCC --> +5V rail on breadboard

IN1 --> Pin 7 on the Uno

Note: If you try and drive all 4 channels of the relay you many need to use external power.  Since I am only driving 1 of the channels I am using the Uno +5V to drive.

Plug the extension cord into the relay.  There are three pins for each relay

  • Normally open
  • Common
  • Normally closed

Plug into the normally open pins.  See picture for help.

Step 2 - Coding Time

Upload the code to the Uno.  Very basic and you can tailor to your needs.

Step 3 - Start Clapping!

  • Plug extension cord into the wall
  • Plug light into extension cord
  • Clap or make loud noise! - Everytime you clap or make a loud noise the relay will toggle on/off

Misc:

  • Change the code to turn on/off with two claps
  • Use relay to drive motors

I hope this is interesting and please provide me with any feedback as i am always willing to learn. Enjoy!!!

Code

ClapperC/C++
Code to listen for sound and toggle relay
/* Clapper
 *
 *  Clap or make loud noise to trigger relay
 *
 */

int relayPin = 7;   //Relay IN1 connected to pin 7
int micPin = 6;   // Mic connected to pin 6
int micVal = HIGH;      //HIGH is no sound, LOW is sound

boolean pwrToggle = true;

void setup ()
{
  Serial.begin(9600);  
  pinMode(relayPin, OUTPUT);  //Set pin for output
    digitalWrite(relayPin, HIGH);  // HIGH is off, LOW is on
  pinMode (micPin, INPUT) ;   //Set pin for input
}
void loop ()
{
  micVal = digitalRead (micPin) ; // Listen...
  
  if (micVal == LOW) // Hear something!!!
  {
      if (pwrToggle == true) {      //relay off (true) Turn it on and display message in serial Monitor
            Serial.println ("Relay on");
            digitalWrite(relayPin, LOW);
            pwrToggle = false;
            delay (500);
      } else {    //relay on (true) Turn it off and display message in serial Monitor
            Serial.println ("Relay off");
            digitalWrite(relayPin, HIGH);
            pwrToggle = true;
            delay (500);
      }
  }
}
 

Schematics

Schematic
Mic, Relay, and Uno Connections
Mic relay v1

Comments

Similar projects you might like

Level Platform Using Accelerometer

Project tutorial by Mark Tashiro

  • 17,580 views
  • 16 comments
  • 31 respects

Portable Arduino Temp/Humidity Sensor with LCD

Project tutorial by ThothLoki

  • 153,307 views
  • 115 comments
  • 185 respects

Control Servos using Wii Nunchuk

Project tutorial by Mark Tashiro

  • 20,313 views
  • 10 comments
  • 70 respects

Food Detector

Project tutorial by crispylel

  • 35,424 views
  • 7 comments
  • 91 respects

Electronic Piano Keyboard With Preset Songs

Project tutorial by Lindsay Fox

  • 77,993 views
  • 60 comments
  • 150 respects

Arduino Kitchen Timer

Project tutorial by Team I and myself

  • 54,461 views
  • 37 comments
  • 77 respects
Add projectSign up / Login