-->
Clap Switch Controller by using ESP8266

Clap Switch Controller by using ESP8266

Clap on Light

Objective:

To implement light automation system which turn on the Lights (LED) by clapping once and turns off after the second clap using microphone module and ESP8266 NodeMCU. It should work as an emergency alarm as well, if one claps fast, it should display an emergency message on the mobile phone and LEDs should blink.






Requirements:                                                                                                                                                   
1.Arduino                                                                                                                                                             
2.Jumpers (M-M)                                                                                                                                                 
3.LED                                                                                                                                                                   
4.Breadboard                                                                                                                                                       
                     

Micro Controller Code





void setup() {
  Serial.begin(115200);
  pinMode(D0, OUTPUT);
}
int flag =0;

void loop() {
  // put your main code here, to run repeatedly:
  int sensorValue = analogRead(A0); 
  float voltage = sensorValue * (5.0 / 1023.0);
  if(voltage>=0.9)
  {
    if(flag == 0)
    {
      digitalWrite(D0,HIGH);
      delay(1000);
      flag =1;
    }
    else if(flag ==1) 
    {
      digitalWrite(D0,LOW);
      delay(1000);
      flag =0;
    }
  }
  Serial.println(voltage);
}





5 Responses to "Clap Switch Controller by using ESP8266"

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel