Hi,
I have a simple program with relay, it shoud work 30 seconds, then 30 seconds off and repeat again and again untill the button at application is pressed.
But it doesn’t work like it should, please advice.
/* Comment this out to disable prints and save space */
#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[] = ""; // Имя Wi-Fi сети
char pass[] = ""; // Пароль Wi-Fi сети
//
BlynkTimer VentilationOnTimer;
BlynkTimer VentilationOffTimer;
int value;
BLYNK_WRITE(V15) // получение значение кнопки timer
{
value =param.asInt();
pinMode(1, OUTPUT);
while (value == 1){
VentilationOnTimer.setInterval(60000, ventilationOn);
VentilationOffTimer.setInterval(30000, ventilationOff);
}
}
void setup()
{
#define BLYNK_PRINT Serial
// Serial.begin(115200);
// 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);
}
void ventilationOff()
{
digitalWrite(1, HIGH);
}
void ventilationOn()
{
digitalWrite(1, LOW);
}
void loop()
{
Blynk.run();
VentilationOnTimer.run();
VentilationOffTimer.run();
}