How long does it take to process a line of code? I have a counter that I want to take one minute between each time it goes through it, but there is also a bunch of code above this:
if (counter >= 15 || counter <= 14)
{
delay(60000);
counter--;
}
if (counter > 14 && < 15)
{
Serial.print("Next toggle will be in less than 15 minutes");
delay(60000);
counter--;
}
if (counter <= 0)
{
(Code that causes toggling)
}
Will this code genuinely take off one minute between each line? I previously had a delay for the time that was inputted, but I am making the counter equal to the input and trying this instead. The inputted time is in minutes.
Impossible to say.
The line of code may be a call to a function that takes an hour to execute, or it may be a simple assignment that takes a hundred or so nanoseconds.
With socking great delays that code takes only as long as the dealy.
By the way that delay(60000) is not 60 seconds because constants unless otherwise stated are ints and they can only hold a number that is just over 32000.
Okay, new way of asking this question. Would these codes take the same amount of time to execute?
{
delay(60000); // I don't care if I can't have a one minute delay, just think theoretically for a few seconds.
}
vs.
{
counter--;
Serial.println("Fifteen minutes until next pulse.");
delay(60000);
}