a question about delay ()....

Hi,

I need to simulate different photoperiod in the laboratory.
I would like to know if I can use the function delay() with values of 43200000 = 12 hours.

is there the possibility to lost syncronization after many days?

This is one of the script I am using:

int ledPin = 9;

void setup() {
}

void loop() {

for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {

analogWrite(ledPin, fadeValue);

delay(17647);
}

delay(41400000);

for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {

analogWrite(ledPin, fadeValue);

delay(17647);

}

delay(43200000);

}

When posting code, please use code tags, makes it much easier to read. This link explains how:
http://forum.arduino.cc/index.php/topic,148850.0.html

valerio83:
I would like to know if I can use the function delay() with values of 43200000 = 12 hours.

Yes.

is there the possibility to lost syncronization after many days?

Yes. You don't say which board you're using, but for example, an Uno uses a ceramic resonator for the system clock which is typically only accurate to ±0.5%.

If that's not good enough, I'd look into a real-time clock (RTC). Inexpensive ones are typically ±20ppm, then there are those based on temperature-compensated crystal oscillators that are as accurate as ±2ppm. The Chronodot is a popular example of the latter.

Hi Jack,

Yes I am using an Arduino uno.

I think that in my case 0.5 % is acceptable!

Thank you

Valerio