Jump to content

PadreSj, stuck!


G+_Rud Dog
 Share

Recommended Posts

PadreSj, stuck!

Attempting to write a sketch via Arduino IDE for the ESP8266. The idea is to have a timer based on date and time ( 3-29-2018 and 08:45:25) which is grabbed using "NPT Web Server" code which I copied and pasted into my code.

Have tried several attempts at this and come up short the "IF" loop seems to drop out early.

 

Here is the idea;

Set duration of time to 15 (minutes)

if the date and time are equal to the set date and time then.

Turn on the pin I/O of choice.

if the duration of time is equal to zero then.

Turn off pin I/O of choice.

Check for next date and time to turn on/off I/O pin.

 

Can send code I have so far just need to clean it up and place on Pastebin if you need to see what I have so far.

Link to comment
Share on other sites

There is one minor problem the "IF" loop turns on the I/O pin every time it loops around so the out put reports the pin being turned on during the entire time it loops.

 

if(HR == setHR && MN <= dur_Timer_MN){

//digitalWrite(output5, HIGH); //Turn on I/O pin

Serial.print("Turn on I/O pin");

}else{

Serial.print("Turn off I/O pin");

//digitalWrite(output5, LOW); //Turn ff I/O pin

 

and the serial monitor shows:

3-29-2018

9:47:31

Turn on I/O pin

3-29-2018

9:47:36

Turn on I/O pin

3-29-2018

9:47:41

Turn on I/O pin

3-29-2018

9:47:46

Here is the entire code with out any housekeeping :

pastebin.com - [C++] Timer - Pastebin.com

 

 

Link to comment
Share on other sites

John Sullivan My apologies for not getting back to you got a bit tangled up trying to figure out the solution using AND,AND,AND,OR,OR.

and this was consuming all my time. After reading what you wrote and reviewing the code you are correct. Seeing about implementing a new approach. Thank you. In essence, the new code will:

Check and compare the hour to a set our if true move to the next condition.

Compare the currents minutes to the length of time I want the I/O on if less than then continue to move to next condition.

If the weekday is equal to 2 or the weekday is equal to 4 or if weekday is equal to 6 then one condition met.

If all three conditions are met the I/O pin will be triggered on and for the duration of the current minutes to the length of time.

Still working on ironing out the wrinkles.

Link to comment
Share on other sites

 Share

×
×
  • Create New...