Guest User

Untitled

a guest
Jan 17th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #define BLYNK_PRINT Serial
  2. #include <ESP8266WiFi.h>
  3. #include <BlynkSimpleEsp8266.h>
  4. BlynkTimer timer;
  5. // You should get Auth Token in the Blynk App.
  6. // Go to the Project Settings (nut icon).
  7. char auth[] = "d58bcc89a7dc46739132d5c03b6dbcb9";
  8. // Your WiFi credentials.
  9. // Set password to "" for open networks.
  10. char ssid[] = "wifi";
  11. char pass[] = "66666666";
  12. int flags=0;
  13. void notifyOnButtonPress()
  14. {
  15. int isButtonPressed = digitalRead(D1);
  16. if (isButtonPressed==1 && flags==0) {
  17. Serial.println("Someone Opened the door");
  18.  
  19. // We allow 1 notification per 15 seconds for now.
  20. Blynk.notify("Alert : Someone Opened the door");
  21. flags=1;
  22. }
  23. else if (isButtonPressed==0)
  24. {
  25. flags=0;
  26. }
  27.  
  28.  
  29. }
  30. void setup()
  31. {
  32. // Debug console
  33. Serial.begin(9600);
  34. //pinMode(D8, OUTPUT);
  35. //analogWrite(D8, 255);
  36. Blynk.begin(auth, ssid, pass);
  37. // Setup notification button on pin D1
  38. pinMode(D1,INPUT_PULLUP);
  39. timer.setInterval(100L,notifyOnButtonPress);
  40.  
  41. }
  42. void loop()
  43. {
  44. Blynk.run();
  45. timer.run(); // Initiates BlynkTimer
  46. }
Add Comment
Please, Sign In to add comment