Introduction: Arduino(nano) Clap Switch
in this tutorial i will be showing you how to make an Arduino clap switch
let's get started!
All you have to do is-
clap once to turn the LED on
and
clap again to turn the LED off
Step 1: ORDER YOUR COMPONENTS:
the components required for this build are:
1xArduino(Any arduino will work)
1x220 ohm resistor
1xLED(Any colour)
1xmicrophone amplifier circuit (variable)
1xBreadboard
some jumper wires or single strand wires
that's all the components!
Now let's move to the next step!
Step 2: CONNECTIONS:
sorry guys, I didn't had the SCHEMATIC so i will tell you all the connections,
here are the connections:
Connect A0 pin of the microphone Amplifier to digital pin 12
Connect GND pin of the microphone amplifier to the GND pin of the Arduino nano
Connect VCC pin of the microphone amplifier to VCC pin of the Arduino nano
Connect one end of the 220 ohm resistor to GND pin of the arduino nano
Connect the other end of the 220 ohm resistor to the cathode(smaller leg of the LED) of the LED
Connect the anode(bigger leg of the LED) to digital pin 12 of the Arduino nano
THAT'S ALL THE CONNECTIONS!
Step 3: THE CODE:
pinMode (micpin, INPUT);
pinMode (ledpin, OUTPUT);
}
void loop() {
if (digitalRead (micpin)==HIGH)
{ if (digitalRead(ledpin)==LOW) { digitalWrite (ledpin, HIGH);} else digitalWrite(ledpin,LOW);
delay(1000);
}
}
Step 4: SUCCESS!
After some small connections and small code we finally get success!
all you have to do is-
clap once the LED turns on
clap again the LED turns off