Hello everybody
Dealing with some blynk related project. the code it self is basic and simple
(Blink with different timing integers applied) but in blynk they say to avoid delays.they recommend using simpleTimer library instead. The code it self runs as programmed but
the problem is that im unable to stop it by pressing the button
when i OFF the button it does shot it down , but after some seconds ( maybe 30) it starts running the loop again.
code attached where am i mistaking? using Wemos d1 r2
Thanks in advance!
#include <ESP8266WiFi.h> // for ESP8266
#include <BlynkSimpleEsp8266.h> // for ESP8266
#include <SimpleTimer.h>
#define BLYNK_MSG_LIMIT 0
BlynkTimer timer;
char auth[] = "~~~~~~"; // Auth Token
char pass[] = "~~~~~~"; // Your WiFi network password
char server[] = "blynk-cloud.com"; // Cloud Server address
int port = 8080; // MCU Hardware Device port int LEDArduino = D5;
void setup() {
pinMode(LEDArduino, OUTPUT);
// Set
up GPIO2 (D4 the ESP On-Board LED) as an
output pin
// Connect to your WiFi network, then to the Blynk Server WiFi.begin(ssid, pass);
Blynk.config(auth, server, port);
Blynk.connect();
timer.setInterval(30000L, []() { // Start 1st Timed Lambda Function - Turn ON LED every 30 seconds (repeating)
timer.setTimeout(200L, []() {(once per loop)
Blynk.virtualWrite(V0, 0); // Turn Virtual LED OFF
digitalWrite(LEDArduino , HIGH); // Turn ESP On-Board LED OFF });
Blynk.virtualWrite(V0, 255);
}); // END 1st Timer Function }
BLYNK_WRITE(V0) {
int pinValue = param.asInt();
Serial.print("Pin number: "); Serial.println(LEDArduino); Serial.println(pinValue);
if (pinValue == 1) {
digitalWrite(LEDArduino, HIGH); // Turn LED on. } else {
digitalWrite(LEDArduino, LOW); // Turn LED off. }
}
void loop() { Blynk.run(); timer.run();
}
Thank you!