How to make a clap switch?? It's really easy to make AC appliances work just by snap or clap, be careful when you are using AC appliances , if you are novice please don't try this without understanding some basic stuff about electronics.
int Torelay = 8; // signal to drive relay
int soundsensor = 7; // input from sound sensor
boolean state = false;
void setup()
{
pinMode(Torelay, OUTPUT);
pinMode(soundsensor, INPUT);
}
void loop()
{
if (digitalRead(soundsensor) == LOW)
{
delay(100);
state = !state;
digitalWrite(Torelay, state);
}
}
--------------------------------------------------------------------------------------------------------------------------
Arduino Program:
--------------------------------------------------------------------------------------------------------------------------
int soundsensor = 7; // input from sound sensor
boolean state = false;
void setup()
{
pinMode(Torelay, OUTPUT);
pinMode(soundsensor, INPUT);
}
void loop()
{
if (digitalRead(soundsensor) == LOW)
{
delay(100);
state = !state;
digitalWrite(Torelay, state);
}
}
--------------------------------------------------------------------------------------------------------------------------
0 comments :
Post a Comment