I do not know why the simple code below does not work. It may have to do with how unsigned long behaves? Code simply determines if elapsed time has exceeded Snooze_Time which is 10000 by comparing the current millis() to the start value of millis().
unsigned long Start_Time;
unsigned long Time_Elapsed;
unsigned long Snooze_Time;
void setup()
{
Snooze_Time = 10000; //Time to start beep
Start_Time = millis();
Serial.begin(250000);
}
void loop() {
Time_Elapsed = millis() - Start_Time;
if (Time_Elapsed >> Snooze_Time)
{
Serial.println("ELAPSED >> SNOOZE");
Serial.print("Time_Elapsed: ");
Serial.println(Time_Elapsed);
Serial.print("Snooze_Time: ");
Serial.println(Snooze_Time);
Serial.println();
}
if(Time_Elapsed << Snooze_Time)
{
Serial.println("ELAPSED << SNOOZE");
Serial.print("Time_Elapsed: ");
Serial.println(Time_Elapsed);
Serial.print("Snooze_Time: ");
Serial.println(Snooze_Time);
Serial.println();
}
}
The early output from the Serial.prints is this, which appears correct.
Then once Time_Elapsed becomes greater than 65533, far greater than 10000, for no apparent reason both if statements pass for Time_Elapsed << 10000 AND Time_Elapsed >> 10000.
If fact, 65539 passes both if conditions
Any help is appreciated.
Time_Elapsed == Snooze_Time
... is that a desired behavior? \$\endgroup\$