Tuesday, November 25, 2014

How to Turn On AC Lights and Fan by clapping using Arduino

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.







Arduino Program:
--------------------------------------------------------------------------------------------------------------------------

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);  
  }
}
--------------------------------------------------------------------------------------------------------------------------

0 comments :

Post a Comment