Triggering a solenoid EVERY FEW DAYS?

I need to write a little arduino program that is going to trigger a solenoid every few days. I’m a newbie programmer. I’m told that millis() will overflow and reset after awhile. If I just do a super long delay is that ok? Will a long delay somehow be affected by millis() resetting? Or be affected by some other clock thing resetting after awhile?

void setup() {     
  pinMode(3, OUTPUT);
}

int count = 96;

void loop() {
  if(count < 96){
    count++;
  }
  else if(count == 96){
    digitalWrite(3,HIGH);
    delay(15000);
    digitalWrite(3,LOW);
    count = 0;
  }
  delay(3600000);
}

"I’m told that millis() will overflow and reset after awhile." You are correct. With proper calculations (current time - earlier time) the overflow will not matter (when it occurs in 49+ days).

Try it: FFFF FFE0 - 0000 0020 = 0000 0040, the proper result.

"If I just do a super long delay is that ok? " That's one way that works. Use 3600000UL as 360000 is more than fits in an INT (I believe this is th default type if not defined).

"Will a long delay somehow be affected by millis() resetting?" No.

"Or be affected by some other clock thing resetting after awhile?" Only loss of power.

You could add an 8-pin real time clock chip, and watch for the next time you want.

millis () overflows every 50 days or so, but this doesn't matter if you test by doing subtraction.

eg.

unsigned long start_time = millis ();

...

if (millis () - start_time >= (3UL * 24UL * 60UL * 60UL * 1000UL))
  {
  // time is up

  }

(The ULs are for Unsigned Long constants). This would test for 3 days to pass (24 hours * 3).

This code will work even over the wrap-around period.

Thank you very much!

have fun waiting for the code to loop to make sure it works...it'll take a day or two :D