So my problem is when i run
If (now.hour() ==00 && now.minute() == 00 && now.second() ==00)
{
Serial.print("hi");
}
I get anywhere from 3-8 hi's
Now. I need to filter that down to one "hi"
How would i go about it?
This has confused me for a bit
So my problem is when i run
If (now.hour() ==00 && now.minute() == 00 && now.second() ==00)
{
Serial.print("hi");
}
I get anywhere from 3-8 hi's
Now. I need to filter that down to one "hi"
How would i go about it?
This has confused me for a bit
Record that you've already sent a 'hi' in this second. Next second, reset that to zero.
Only print when second becomes zero.
See the StateChangeDetection example in the IDE
The thing is second stays 0 for well a second.
Which is enough time for the arduino to fire off a few zeros.
So i get a few hi's.
I need only one
Like a delay but i dont even think millis() would help me right now...
Ive tried everything..
Also note, writing 00 is fine but do not the leading 0 indicates octal notation so 010 != 10 and 09 is NOT valid
Aka, don't get into the habit of writing leading zero's if you don't mean octal ![]()
The thing is second stays 0 for well a second.
Yes, but it only changes to 0 once a minute. Catch that change of state and print when it occurs.
bool hiSent = false;
void loop()
{
// Get the time
if (now.hour() ==00 && now.minute() == 00 && now.second() ==00)
{
if(!hiSent)
{
Serial.print("hi");
hiSent = true;
}
}
else
{
hiSent = false;
}
}
What the f**k this has to do with count++ is a complete mystery.
It has to do with count to count days. Duh!
And i just used now.day() instead
Isn't that as simple as
if(now.day() != lastDay){
lastDay = now.day();
days++;
}