Clap Switch Sound Sensor DIY Kit

clap switch

This kit is available on eBay for less than £2 and I purchased mine from here. The PCB is of reasonable quality and screen printed with all the component values that make it easy to build this project. Several components need to be connected in one direction, the two electrolytic capacitors easy to align as the negative is shown shaded, the two small diodes have a black band on one end and both are aligned in the same direction. The symbol for a diode is printed on the PCB and the bar on the symbol represents the black band on the component. There are four transistors and they should be inserted on the board so that the flat on the transistor aligns with the flat printed on the board. The microphone position shows a + and a -, but no markings were printed on my microphone. However, the pins are offset and the microphone can only be fitted one way so that it fits inside the printed circle. The last component the needs fitting correctly is the LED, this has one leg longer than the other and, more importantly, a flat on one side. The LED is aligned so that it faces to the edge of the PCB, if it is fitted the wrong way round the completed board will not work.

All the remaining components can be fitted either way round, resistors need to have their their leads bent close to the body. There are two values of capacitor, 0.1mfd and 0.01mfd (marked as 104 and 103 respectively), fit the 103 first, then fit 104 capacitors to avoid fitting the 103 in the wrong place. The power socket should obviously be fitted with the open end facing the edge of the board. I soldered a two pin plug to the supplied power lead so that it could be plugged into the Arduino 5volt and Gnd.

Once everything is soldered you will probably find a small printed rectangle alongside the LED with two holes, mine was printed with Link. At first I thought I had a missing component or a small wire link was required, but checking the copper side of the PCB showed one of the solder pads was connected to the 5volt track and the other solder pad was on a copper track alongside the 5volt track. I suspected that this may be the output from the Clap Switch and decided to fit a two pin male header. However, the hole spacing was not exactly 0.1 inches and I had to very carefully enlarge the holes. Be very careful not to destroy the solder pads or push the off the board if you do this! The alternative is to simply solder two leads into these holes, it’s up to you.

The board is very compact and the solder pads vey close together so be careful not to short pads. I use a stiff brush and alcohol to clean all the flux etc from the board after soldering. Use a magnifying glass to check for dry joints and shorts. Once you are happy all is well you can connect to a 5 volt supply or use the 5volt and Gnd pins on an Arduino. The LED will light up (it did on mine, but this may be random). Clap your hands about 1 foot from the microphone and the LED will change state. Clap again and it will change state again.

I suspect, although I have not checked, that the circuit is a microphone pre amplifier with its output fed into a bistable flip flop similar to this one


Which is why the output remains in one state and need another trigger to switch to the other state. I used a multimeter connected to the two pins I had soldered alongside the LED, when the LED was lit it showed about 4.8volts and when the LED was off it showed just under 1 volt. The pin closest to the edge of the board is always 5 volts, so I ignored that on, the other pin will be equivalent to HIGH when the LED is not lit and LOW when lit.

I use the term Clap Switch Output pin to identify the pin circled in red below. The pin above this is connected to the 5volt PCB track and can be ignored. It is important that the Gnd of the Clap switch is connected to the Arduino Gnd, but if it is powered from the Arduino this will happen automatically.

I did try using the output from the Clap Switch to trigger an interrupt on the Arduino pin 2 and this worked well in a quiet room, however the results were erratic with background noise. There is no rush to read the state of the switch, simply read the state at a convenient point in your sketch. The sketch below shows how this can be done, it reads the voltage on pin A0 and sets the variable trigger to False if it is above 2 volts and True if it is below 2 volts. The onboard LED on pin 13 is the lit if  trigger is True.

/***********************************************************
Clap Switch Simple Control
by
Chris Rouse
May 2016

Connections:

Vcc to Arduino 5 volts
Gnd to Arduino Gnd
Output to Arduino Analog pin 0

***********************************************************/
const byte ledPin = 13;
boolean trigger = false; // used to show clap output ON
int triggerLevel = 100; // change this if background noise is high
int outputReading; // voltage output from Clap Switch

/*********************************************************/
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW); // turn LED OFF
}
/*********************************************************/
void loop() {
checkSwitch(); // see if the switch has been triggered
if(trigger){
digitalWrite(ledPin, HIGH);
}
else{
digitalWrite(ledPin, LOW);
}
//

// put the rest of your program here

//
}
/*********************************************************/
void checkSwitch() {
outputReading = analogRead(14);
if(outputReading > triggerLevel){
trigger = false;
}
else{
trigger = true;
}
}
/*********************************************************/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s