Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define BLYNK_PRINT Serial
- #include <ESP8266WiFi.h>
- #include <BlynkSimpleEsp8266.h>
- BlynkTimer timer;
- // You should get Auth Token in the Blynk App.
- // Go to the Project Settings (nut icon).
- char auth[] = "d58bcc89a7dc46739132d5c03b6dbcb9";
- // Your WiFi credentials.
- // Set password to "" for open networks.
- char ssid[] = "wifi";
- char pass[] = "66666666";
- int flags=0;
- void notifyOnButtonPress()
- {
- int isButtonPressed = digitalRead(D1);
- if (isButtonPressed==1 && flags==0) {
- Serial.println("Someone Opened the door");
- // We allow 1 notification per 15 seconds for now.
- Blynk.notify("Alert : Someone Opened the door");
- flags=1;
- }
- else if (isButtonPressed==0)
- {
- flags=0;
- }
- }
- void setup()
- {
- // Debug console
- Serial.begin(9600);
- //pinMode(D8, OUTPUT);
- //analogWrite(D8, 255);
- Blynk.begin(auth, ssid, pass);
- // Setup notification button on pin D1
- pinMode(D1,INPUT_PULLUP);
- timer.setInterval(100L,notifyOnButtonPress);
- }
- void loop()
- {
- Blynk.run();
- timer.run(); // Initiates BlynkTimer
- }
Add Comment
Please, Sign In to add comment