Monday, July 6, 2015

Clap sensitive switch using Arduino((basic version)

The circuit diagram of the circuit is shown in the diagram below.


The code of clap sensitive circuit is shown below. the mic and a 47 k resistor are connected in series making voltage divider and the divided voltage is sent to the analog input pin A0 of the arduino. the led is joined in pin 12 of digital i/o line of arduino. to make it work open the serial monitor and check the value without clapping and with clapping and eg if the value show is 30 without clapping and 500 with clapping then write val > 50 in if else statement. the working video of the circuit is at youtube . click the following link https://www.youtube.com/watch?v=oi7IaTbd9Gs

int clapsense=A0;
int led=12;
int state=LOW;



void setup() {
pinMode(clapsense,INPUT);
pinMode(led,OUTPUT);
Serial.begin(9600);
}

void loop() {
int val=analogRead(clapsense);
Serial.println(val);
if(val>50 && state==LOW)
{
  digitalWrite(led,HIGH);
  state=HIGH;
}
else
if(val>50 && state==HIGH)
{
  digitalWrite(led,LOW);
  state=LOW;
}

}

demo video 





No comments:

Post a Comment