-
Notifications
You must be signed in to change notification settings - Fork 0
/
Code
35 lines (30 loc) · 761 Bytes
/
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timer;
char auth[] = "*******************"; //here goes your Blynk authentication code
char ssid[] = "ABC"; //here goes your username
char pass[] = "******"; //here goes your password
int flag = 0;
void notifyOnButtonPress()
{
int isButtonPressed = digitalRead(D1);
if(isButtonPressed == 1 && flag == 0){
Serial.println("Someone Opened the Door");
Blynk.notify("ALERT: Someone Opened the Door");
}
else if(isButtonPressed == 0)
flag = 0;
}
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pinMode(D1, INPUT_PULLUP);
timer.setInterval(16000L, notifyOnButtonPress);
}
void loop()
{
Blynk.run();
timer.run();
}