Hi.
I have a simple program, there are 2 buttons, which are assigned to virtual pin 127 and 128.
If the 1st button is pressed, the flag (K) is increasing by 1, if the 2nd button is pressed, same story with flag (L).
If “K” and “L” =1, then I have to receive the message at terminal: “Working”.
But unfortunatelly, it isn’t working.
Please advice.
#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[] = "";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "1TP1";
char pass[] = "";
int K=0; // флаг
int L=0; // флаг 2
BLYNK_WRITE(V127) // обработчик кнопки калитка
{
int pinData = param.asInt();
if(pinData==1){
K=1+K; // просто устанавливаю флаг по клику кнопки , причем флажок устанавливается в момент нажатия кнопки
}
}
BLYNK_WRITE(V128) // обработчик кнопки калитка
{
int pinData = param.asInt();
if(pinData==1){
L=1+L; // просто устанавливаю флаг по клику кнопки , причем флажок устанавливается в момент нажатия кнопки
}
}
// Attach virtual serial terminal to Virtual Pin V1
WidgetTerminal terminal(V1);
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
// This will print Blynk Software version to the Terminal Widget when
// your hardware gets connected to Blynk Server
terminal.println(F("Blynk v" BLYNK_VERSION ": Device started"));
terminal.println(F("-------------"));
terminal.println(K);
terminal.println(L);
terminal.flush();
}
void loop()
{
if(K==1 && L==1){
terminal.println(K);
terminal.println(L);
terminal.println("Working") ;
terminal.flush();
}
Blynk.run();
}