Skip to content

Commit 0d0b549

Browse files
author
oclyke
committed
Convert Example2 loop to non-blocking
This allows the user to see that the alarm fired 'exactly' when they wanted it to.
1 parent d3bd832 commit 0d0b549

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

libraries/RTC/examples/Example2_Set_Alarms/Example2_Set_Alarms.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,11 @@ void loop()
6363
}
6464

6565
// Print RTC's date and time while waiting for alarm
66-
printDateTime();
67-
delay(1000);
66+
static uint32_t nextPrint = 0;
67+
if(millis() > nextPrint){
68+
printDateTime();
69+
nextPrint = millis() + 1000;
70+
}
6871
}
6972

7073
// Print the RTC's current date and time

0 commit comments

Comments
 (0)