Created
November 23, 2021 13:20
-
-
Save stonehippo/9667aed25fc45b7f42f17b79e7287bd3 to your computer and use it in GitHub Desktop.
A trivial Arduino application showing delaying an event synchronously for some number of minutes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define SECOND 1000 // 1 sec = 1000 millseconds | |
#define MINUTE 60 * SECOND // 60 sec = 1 minute | |
void setup() { | |
Serial.begin(115200); | |
randomSeed(analogRead(0)); // choose a pseudo-random starting seed | |
} | |
void loop() { | |
WaitForNMinutes(); | |
} | |
void WaitForNMinutes() { | |
long minutes = random(1,60); // generate a value between 1 and 60, inclusive | |
Serial.print("Waiting for "); Serial.print(minutes); Serial.println(" minutes"); | |
delay(minutes * MINUTE); | |
Serial.println("Ok, done waiting!"); | |
Serial.println("-----"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment