Hello. I am trying to get a function to execute at precise times. Every 15 minutes, so at 00, 15, 30 and 45 minutes after the hour. I have a clock running and I tried this code, but it always runs the function no matter what.
Any ideas? I guess I would also need to know how to make sure it runs only once during that minute instead of constantly running during that minute. Thank you.
Your syntax for the if statement is completely wrong. You must explicitly specify each condition. Also, if the minute() function returns an integer then the comparisons are always going to fail. Try this:
I appologize for the bad syntax. As for all the single quotes, I got mixed up on when to use them. According to PaulS, I was trying to invent shortcuts. Sorry, but that was not my intent. If I knew what I was looking for, I'd have looked for it.
el_supremo, yes that worked great. Thank you for your help and I commend your skill at not belittling or being sarcastic.
There is one problem with the way the statement is constructed which can lead to very intermittent weirdness. The problem is that if you happen to be at the minute boundary when the statement is executed it could fail to detect that it should have executed sendUpdate();
For example, if the current minute is 45, but just before "minute() == 45" is evaluated the time ticks over to 46, the update won't occur.
The safest thing is to do something like this:
int now = minute();
if(now == 0 || now == 15 || now == 30 || now == 45) {
That way the time can't change while the if statement is evaluated.