Tell me please ! It is necessary to control a single output with physical buttons and applications? if the code is correct or it is necessary to correct?
#define BLYNK_DEBUG
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
char auth[] = "YourAuthToken";
void checkPhysicalButton();
const int butdoorbell = 4;
const int doorbell = 13;
SimpleTimer timer;
int ledState = LOW;
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, "ssid", "pass");
digitalWrite(doorbell, ledState);
pinMode(doorbell, OUTPUT);
pinMode(butdoorbell, INPUT);
timer.setInterval(300L, checkPhysicalButton);
}
BLYNK_CONNECTED()
{
Blynk.syncAll();
}
BLYNK_WRITE(V10){
ledState = param.asInt();
digitalWrite(doorbell, ledState);
}
void checkPhysicalButton()
{
if (digitalRead(butdoorbell) == HIGH){
digitalWrite(doorbell, HIGH);
Blynk.virtualWrite(V10, HIGH);
}
if (digitalRead(butdoorbell) == LOW){
digitalWrite(doorbell, ledState);
Blynk.virtualWrite(V10, ledState);
}
}
void loop()
{
Blynk.run();
timer.run();
}