The Planted Tank Forum - View Single Post - Hunter X's Arduino Whole Tank Controller (52K Warning)
View Single Post
Old 04-09-2014, 05:20 AM   #170
bigd603
Planted Member
 
PTrader: (1/100%)
Join Date: May 2011
Location: Portland, OR
Posts: 260
Default

Quote:
Originally Posted by benjaf View Post
Nice to see someone is making progress!
Any particular reason for using millis rather than a timestamp from the RTC? If you do want to use millis you will have to handle rollover. That could be done with something like this:
Code:
 
if (currentMillis - lastXivelyPut > putInterval) 
{ ... }
else if(currentMillis < lastXivelyPut) {
lastXivelyPut = 0;
}
Thanks Benjaf, I didn't do the RTC time stamp at first because I was also worried about a rollover scenario (if it checked if lastXivelyPut >= second() + 9 or something like that) when the second rolled over into the next minute. But thinking about it, I could just have it check if second = 0, 10, 20, 30, 40, or 50. That would give me the same result without worrying about a rollover. Thanks!
bigd603 is online now   Reply With Quote