I am using NODE MCU ESP8266 With Blynk app,
Problem : - When connecting to Blynk first time after power reset ESP8266 GPIO connected LED automatically ON whiteout button press.
Program as Below.
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[ ] = "xxxxxxxxxxxxx";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[ ] = "xxxxx";
char pass[ ] = "xxxxxxx";
WidgetLED led1(V1);
BlynkTimer timer;
// V1 LED Widget is blinking
int DO4,DO5;
int value,value1;
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
}
//In the loop function include Blynk.run() command.
void loop()
{
Blynk.run();
timer.run();
DO4 = digitalRead(4);
DO5 = digitalRead(5);
if(DO4==HIGH)
{
Blynk.virtualWrite(V8,0);
}
else
{
Blynk.virtualWrite(V8,255); //LED "LOW"
}
if(DO5==HIGH)
{
Blynk.virtualWrite(V9,0);
}
else
{
Blynk.virtualWrite(V9,255); //LED "LOW"
}
}