blynk simpleTimer relay

Hello everybody
I am very new to programing, hence due to lack of knowledge & experience run into trubles.
Your help is highly appreciated!
I am trying to set a mosfet (or a relay) to go ON for 30 seconds
than oFF for 250 (1/4 of a second 25%) and than back on for 30 seconds &off for 250 (1/4 of a second thats the whole loop it is recommended avoid using mills function with blynk but to use SimpleTimer library
Used the example sketch below, it outputs that loop (30 seconds on 1/4 second off)
but the the problem is i cant turn it off completely. namely, when i press the digital button to OFF it shots down for 30 seconds and than turns on and it starts over
How to add a function which will enable to complete shot down the wemos pin pin

Wemos D1R1

Thanks in Advance!

#include <ESP8266WiFi.h> // for ESP8266
#include <BlynkSimpleEsp8266.h> // for ESP8266
#define BLYNK_MSG_LIMIT 0 // In theory this disables the “anti-flood governor”… might only work on Local Server

BlynkTimer timer;

char auth[] = “"; // Auth Token
char ssid[] = “I’m AweSome”; // Your WiFi network name
char pass[] = "”; // Your WiFi network password
char server[] = “blynk-cloud.com”; // Cloud Server address
int port = 8080; // MCU Hardware Device port

void setup() {
pinMode(2, OUTPUT); // Setup 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();

// This dual nested timer routine will constantly blink both a Virtual LED and the onboard LED of an ESP8266 Dev Board
timer.setInterval(30000L, { // Start 1st Timed Lambda Function - Turn ON LED every 2 seconds (repeating)
timer.setTimeout(250L, { // Start 2nd Timed Lambda Function - Turn OFF LED 1 second later (once per loop)
Blynk.virtualWrite(V0, 0); // Turn Virtual LED OFF
digitalWrite(2, HIGH); // Turn ESP On-Board LED OFF
}); // END 2nd Timer Function
Blynk.virtualWrite(V0, 255); // Turn Virtual LED ON
digitalWrite(2, LOW); // Turn ESP On-Board LED ON
}); // END 1st Timer Function
}

void loop() {
Blynk.run();
timer.run();
}

THANKS VERY MUCH!

Did this timer implementation work for you?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.