Time input blynk digital pin

what should I do now?

Aside from all the prior suggestions? I don’t know… how did they work out first?

Will it work on another board. For example nodemcu ESP8266?

Will what work? the Time Input Widget?? Yes, it is just a simple data transfer widget and will work on any device that can run Blynk… it is your code that takes the widget’s input and makes it work… again on any device.

hello. can someone reply me the code of time input included digital pin 13 (led). connection to blynk - usb. thank you in advance

You already have a topic about this… and we do not exist to custom make your code :stuck_out_tongue:

I know​:joy: But example code is just useless. How it will control something when there is no digital pin written!!:joy:

We already showed you the resources you need to learn that, in this topic… of which I merged your last few posts back into.

Or… as I also already stated… if you just want a dirt simple timer to control a pin, use the Timer Widget or even Eventor.

I need to set days too and timer widget doesn’t have this option

Then look back up in this topic and start re-reading the Advanced Time Input references.

#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("----------");
}

Will it work if I change this code for usb connection?

Sure, why not. But you have to account for other factors concerning UNO vs ESP8266 as well… like changing the Blynk library file used and GPIO pin numbering.

#define BLYNK_PRINT Serial
#include <WidgetRTC.h>
BlynkTimer timer;
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11); // RX, TX
#include <BlynkSimpleStream.h>
char auth[] = "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(13, OUTPUT);  // Built-in LED
  digitalWrite(13, LOW); // Turn OFF built-in LED
  Serial.begin(9600);  // Debug console
  Blynk.begin(Serial, auth);
  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(13, HIGH); // 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(13, LOW); // 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("----------");
}

there is something wrong :frowning: :frowning:

heelp