Hi i want to pause my program for 5mins exactly but I'm not sure how to do it without typing too many delay(1000). Could anyone help me with this? Thanks guys!
Easy!
delay(1000*60*5);
Or read and learn from this superb thread: Demonstration code for several things at the same time - Project Guidance - Arduino Forum
How exact do you need the timing to be ?
delay() take milliseconds as its parameter.
So you could use delay(5 * 60 * 1000UL);
5 minutes, each of 60 seconds each of 1000 milliseconds
Or you could put the delay() in a for loop
for (int x = 0; x < 300; x++)
{
delay(1000);
}
Either way the program will do nothing during the waiting period.
Or much better you could use the principle shown in the BlinkWithoutDelay example in the IDE and not use delay() at all. It would be a good idea to do this because you are certainly going to need to use it at some time. to perhaps stop the 5 minute wait early.
nwzh:
without typing too many delay(1000)
Please tell me that doesn't mean you thought delay() could only have a value of 1000?
(But that aside, as you'll see in the linked thread above, not using delay() at all is a superior solution.)
Look at how mills() is used for timing as illustrated in several things at a time.
...R
Sweeduino:
Easy!delay(1000*60*5);
Sadly, unless you're on a 32 bitter, it certainly isn't that easy.