Need help making a loop

The programmer on this project has completely disappeared.. very strange but I must move on.

I need to execute this code only once, then disable it for 24 hours. My beginners luck has run out and need some help finishing up this project.

if ((batteryCheck() != BATTERY_OK) || (clockBatteryCheck() != BATTERY_OK) && (!isBypassOn())) {
if (isValveOpen) {
closeValve();
goToDefaultMenu();
return;
}
}

Thanks!!

How accurate this 24 hour period has to be?

Do you have any external form of time standard available or are you going to rely on the not very accurate Arduino oscillator to provide the timing ?

If absolutely nothing else is going on in the program you could simply put a huge delay() in the in the loop() function but a smarter way would be to use the BlinkWithoutDelay principle as shown in the example with that name in the IDE.

Either way the code that you posted should be in a function called at the appropriate time from the loop() function.

Please post the whole program as it is in order to get help in the context of the program.

The problem we're having is that battery detection needs to happen first so when the battery is low, it closes the valve and alerts the user but we need to allow a 24 hour period for the valve to open back up but have been unable to because of the statement telling the system to close the valve when the battery is low.

We're using the 'DS1307RTC' and 'Time' libraries.

I'm not opposed to using the delay method but I can't see a way to use that only once after the battery low condition has been detected.

I could make another void function but it would still need to be run system wide so that the battery condition can be checked.

This is why I wanted to make a loop that checks to see if it has run a certain statement or function already and won't allow it to run again until 24 hours have passed.

I suggest that you post the whole of the program so that advice can be given in the proper context.

As you are using an RTC there delay method, which is a kludge at the best of times, is not appropriate. The RTC will provide a mechanism for timing 24 hours.

I wanted to make a loop that checks to see if it has run a certain statement or function already and won't allow it to run again until 24 hours have passed.

You already have the loop() function so you don't need another loop. When the function has run set a flag variable to true to denote the fact then don't run the function again for 24 hours if the flag is set.

UKHeliBob:
You already have the loop() function so you don't need another loop. When the function has run set a flag variable to true to denote the fact then don't run the function again for 24 hours if the flag is set.

That's exactly what we need to do. Would you know the code to do that?

Learn BlinkWithoutDelay.

It's in your IDE under Examples.

Here's the Arduino site Tutorial page on it:

A complete lesson on the how, why and what explanation of when is in the first link at the bottom of my posts.

Would you know how to do that with the 'Time' library? 24 hours in milliseconds is a lot of numbers! I should also mention that we're working with a custom board but we're using the arduino micro-controller and IDE to load sketches.

GoForSmoke:
Learn BlinkWithoutDelay.

It's in your IDE under Examples.

Here's the Arduino site Tutorial page on it:
http://arduino.cc/en/Tutorial/BlinkWithoutDelay

A complete lesson on the how, why and what explanation of when is in the first link at the bottom of my posts.

If you learn the simple sketch then you won't need any library.

unsigned long timeInMillis; // can hold 49.7 days in milliseconds, over 4 billion.

If you want accurate time then you need a Real Time Clock and you will use the library it uses.