it’s connected and working, but the aleart doesn’t work What’s the problem?
//#define BLYNK_TEMPLATE_ID "TMPxxxxxx"
//#define BLYNK_TEMPLATE_NAME "Device"
//#define BLYNK_AUTH_TOKEN "XXXXXXX"
#include "BlynkEdgent.h"
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define DOOR_SENSOR 4
#define led 16
BlynkTimer timer;
char auth[] = "XXXXXXXXXXXXXXXXXX";
char ssid[] = "GXXXXX"; // WiFi 네트워크 이름
char pass[] = "12XXXXX"; // WiFi 비밀번호
int flag=0;
void notifyOnButtonPress()
{
int isButtonPressed = digitalRead(DOOR_SENSOR);
if (isButtonPressed==1 && flag==0) {
Serial.println("Someone Opened the door");
Blynk.logEvent("alert", "Someone opened the Door");
digitalWrite(led, HIGH);
flag=1;
}
else if (isButtonPressed==0)
{
flag=0;
Serial.println("Door Closed");
digitalWrite(led, LOW);
}
}
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pinMode(DOOR_SENSOR, INPUT_PULLUP);
pinMode(led, OUTPUT);
timer.setInterval(10000L, notifyOnButtonPress);
}
void loop()
{
Blynk.run();
timer.run();
}
'''

