Pages: [1]   Go Down
Author Topic: Start up delay  (Read 337 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 How do I get a delay at the start of the loop? that only happens once. ie I power up the arduino. It waits five seconds before running through loop(). But the five second delay doesnt happen each time it goes through the loop?

Code:
loop()
{
delay(5000);
}

Gives a five second delay every time the loop is executed, i just want to have it delay just once, at the beginning.
Logged

Lancashire, UK
Offline Offline
Edison Member
*
Karma: 8
Posts: 1992
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Easy, you just put the delay in the setup() part of the sketch.
Logged


Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16499
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How do I get a delay at the start of the loop? that only happens once. ie I power up the arduino. It waits five seconds before running through loop(). But the five second delay doesnt happen each time it goes through the loop?

Code:
loop()
{
delay(5000);
}

Gives a five second delay every time the loop is executed, i just want to have it delay just once, at the beginning.

Simply put the 5 second delay command as the last statement of your void setup() section.

Lefty
Logged

Pages: [1]   Go Up
Jump to: