Introduction: Clap Switch

About: I am just an electronic hobbyist and a student. I make projects for just fun I hope you will like my projects and appreciate my work.

This is my first instructables post , this my self built

clap switch.

Step 1: Grab Your Components

You will need
Arduino UNO x1
P channel MOSFET x1
TDA2822 opamp x1
Condenser microphone x1 (you should just salvage one)
Some jumper cables and breadboard
Relay x1

Step 2: Put Your Components on the Breadboard

Hook it up everything as shown in the schematic and upload

the code provided. If you are using a N channel mosfet you need to change the ‘analogWrite(led, 1);’ with ‘analogWrite(led, 255);’

And ‘analogWrite(led, 255);’ with ‘analogWrite(led, 1);’.

Step 3: Attach Everything and Power It Up

You will need two power supplies one for the arduino and one

for the switching of the relay.

The circuit works on 5v don’t give more than 5v otherwise the circuit will be blown up.

Step 4: Upload the Code

upload the code. And BTW you can use any Arduino and even one attiny85.

Here is the code:
int buf;
int led = 6;
int button = A1;
int ledstate;
int buttoncurrent;
void setup() {
pinMode(A1, INPUT);
pinMode(led, OUTPUT);
analogWrite(led, 255);
buf = 0;
}

void loop() {
buttoncurrent = analogRead(button);
while(buttoncurrent > 150){
analogWrite(led, 1);
buf = 1;
if(buttoncurrent > 150 && buf == 1){
analogWrite(led, 255);
buf = 0;
}
}