Blink without Delay Sketch, this line:

// constants won't change :
const long interval = 1000; // interval at which to blink (milliseconds)

Tells how long to wait til the next state.

Is there a maximim time ?

Can it go for several minutes??

Thanks, Chuck

Can it go for several minutes??

Work out the value and try it for yourself but the answer is yes. In fact it can go up to nearly 50 days if done correctly (which it is not in the BWOD example)

Thank you for the reply, so I just use milliseconds for the time, so 60000 is one minute?

Also I thought I read somewhere that after the 50 days it quits, would that apply in this case?

I will get a board set up this evening.

Thanks,
Chuck

so I just use milliseconds for the time, so 60000 is one minute?

Yes

Also I thought I read somewhere that after the 50 days it quits, would that apply in this case?

It does not "give up" but the value of millis() resets to zero after 49 and a bit days so simple maths will get the answer wrong in

``````  if(currentMillis - previousMillis >= interval)
``````

Note that the 49 day feature (rollover) only happens if the Arduino has been on continuously for that period of time. If it is reset or powered down for example, that counter starts over so it is not like 49 days after you start it rolls over even if it was reset or something.

You need to use unsigned long also, so you have 0 to 2^32-1 number, (0x0000 to 0xFFFF)
vs long, which yields a signed number, +/- 2^31. (0x8000000 to 0x8FFFFFFF are negative, 0x0 to 0x7FFFFFFF are positive).

``````  if(currentMillis - previousMillis >= interval)
``````

Simple subtraction yields the correct result.
Say previousMillis was just before rollover, at 0xFFFFFFF0, and currentMillis was after the rollover, 0x0000000F.
Then 0x0000000F - 0xFFFFFFF0 = 0x0000001F as expected. Try it with your calculator in Programmer mode.
The answer returned is 0xFFFFFFFF0000001F. Throw aware the upper 8 digits, because they don't exist in Arduino (32-bit math for millis() and micros(), and you get 0x0000001F. So rollover is not a factor with simple substraction of later time minus earlier time, and comparing to be >= an interval.

So rollover is not a factor with simple substraction of later time minus earlier time, and comparing to be >= an interval.

As long as the interval does not exceed the maximum value of millis()

Thanks guys for all of your help.
This is going to be fun.