Missing something with attempt to understand Advanced Time Input

I agree wholeheartedly… most current examples offer semi-theoretical use cases, fine for those that can handle some coding, but no good for those that literally want a copy/paste “Pushenzee buttons and watchenzee blinkin lights” example.

However, I believe the developers are working on some totally improved & advanced Sketch Builder routines…


Meanwhile, here is my “final”? relatively copy/paste-able, start and stop time only (all days of the Week), shows stuff and toggles a digital pin (built-in LED on Wemos D1 Mini), example :stuck_out_tongue:

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <WidgetRTC.h>
BlynkTimer timer;
char auth[] = "xxxxxxxxxx";
char ssid[] = "xxxxxxxxxx";
char pass[] = "xxxxxxxxxx";
char currentTime[9];
char startTime[9];
char stopTime[9];
int SThour;
int STmin;
int STsec;
int SPhour;
int SPmin;
int SPsec;

WidgetRTC rtc;  // Set RTC widget.

void setup()
{
  pinMode(2, OUTPUT);  // Built-in LED
  digitalWrite(2, HIGH); // Turn OFF built-in LED
  Serial.begin(115200);  // Debug console
  Blynk.begin(auth, ssid, pass);
  rtc.begin();
  setSyncInterval(360);
  timer.setInterval(30000L, TimeCheck);  // Update Time Check every 30 seconds
}



BLYNK_CONNECTED() {
  Blynk.syncVirtual(V1); //  Synchronize Time Input Widget when connected
  TimeCheck(); // Initial Time Check
}


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



BLYNK_WRITE(V1) {  // Called whenever setting Time Input Widget
  TimeInputParam t(param);
  SThour = t.getStartHour();
  STmin = t.getStartMinute();
  STsec = t.getStartSecond();
  SPhour = t.getStopHour();
  SPmin = t.getStopMinute();
  SPsec = t.getStopSecond();
}



void TimeCheck() {  // call with timer every 30 seconds or so
  // Get RTC time
  sprintf(currentTime, "%02d:%02d:%02d", hour(), minute(), second());
  Serial.print("Current Time: ");
  Serial.println(currentTime);

  // Get Time Input Widget time
  sprintf(startTime, "%02d:%02d:%02d", SThour, STmin, STsec);
  Serial.print("Start Time: ");
  Serial.println(startTime);

  sprintf(startTime, "%02d:%02d:%02d", SPhour, SPmin, SPsec);
  Serial.print("Stop Time: ");
  Serial.println(startTime);

  if (hour() == SThour) {
    if (minute() == STmin) {
      Serial.println("Doing something now");
      digitalWrite(2, LOW); // Turn ON built-in LED
    } else if (minute() < STmin) {
      Serial.println("Will do something");
    } else if (minute() > STmin) {
      Serial.println("Did something");
    } else {
      Serial.println("Clueless");
    }
  }

  if (hour() == SPhour) {
    if (minute() == SPmin) {
      Serial.println("Stopping something now");
      digitalWrite(2, HIGH); // Turn OFF built-in LED
    } else if (minute() < SPmin) {
      Serial.println("Will stop something");
    } else if (minute() > SPmin) {
      Serial.println("Stopped something");
    } else {
      Serial.println("Clueless");
    }
  }
  Serial.println("----------");
}
[5887] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.5.0 on Arduino

[5893] Connecting to 10.10.3.13:8442
[10894] Connecting to 10.10.3.13:8442
[10923] Ready (ping: 19ms).
[11069] Time sync: OK
Current Time: 12:40:21
Start Time: 12:41:00
Stop Time: 12:42:00
Will do something
Will stop something
----------
Current Time: 12:40:51
Start Time: 12:41:00
Stop Time: 12:42:00
Will do something
Will stop something
----------
Current Time: 12:41:21
Start Time: 12:41:00
Stop Time: 12:42:00
Doing something now
Will stop something
----------
Current Time: 12:41:51
Start Time: 12:41:00
Stop Time: 12:42:00
Doing something now
Will stop something
----------
Current Time: 12:42:21
Start Time: 12:41:00
Stop Time: 12:42:00
Did something
Stopping something now
----------
Current Time: 12:42:51
Start Time: 12:41:00
Stop Time: 12:42:00
Did something
Stopping something now
----------
Current Time: 12:43:21
Start Time: 12:41:00
Stop Time: 12:42:00
Did something
Stopped something
2 Likes