best way to delay one minute

I'm wondering which I should use to put a one minute delay between random case selection.


This:

for(count = 0; count < 60 ; count++)
{
delay(1000);
}


or

unsigned long previousMillis = 0;

const long Interval = (1*60 * 1000UL);

Void loop(){

unsigned long currentMillis =millis();

if (currentMillis - previousMillis >=Interval) {

previousMillis = currentMillis;


The first way seems easier when using cases.

Thanks

The nice thing about using millis() is you can do other stuff while waiting on the time period to expire. If you do it the first way you don't need a for loop just execute delay(60000).

ToddL1962:
The nice thing about using millis() is you can do other stuff while waiting on the time period to expire. If you do it the first way you don't need a for loop just execute delay(60000).

Well, I want it to do nothing in between cases, But, I thought I read that delay(60000); won't work.

What does “best way” mean ?


Did you try delay(60000);

Polliwog:
Well, I want it to do nothing in between cases, But, I thought I read that delay(60000); won't work.

It will work.
What won't work is "delay (60 * 1000);" because the arithmetic will be done as "int", and 60000 doesn't fit in a 16 bit int.

Tanks guys :slight_smile:

TheMemberFormerlyKnownAsAWOL:
It will work.
What won't work is "delay (60 * 1000);" because the arithmetic will be done as "int", and 60000 doesn't fit in a 16 bit int.

Wouldn't delay(60.0 * 1000.0) work?

delay (60 * 1000ul);

Polliwog:
I'm wondering which I should use to put a one minute delay between random case selection.

const long Interval = (1*60 * 1000UL);

You can also

const long Minutes = 1;
const long Interval = (Minutes * 60 * 1000);

If later you want to do 7 minutes or something, it's easy to change...

Thanks to everyone