diff options
author | Jonas Smedegaard <dr@jones.dk> | 2025-03-09 15:25:02 +0100 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2025-03-09 15:25:02 +0100 |
commit | 0f33d88c94eafcfe980a56ab66d0d2c0e574968c (patch) | |
tree | 370824e012b47604ef42ba093316eae73c715a1f /mussel2 | |
parent | a61337c4e285d5e55b750800d470d7dbd96e4643 (diff) |
separate function read() from main loop()
Diffstat (limited to 'mussel2')
-rw-r--r-- | mussel2/mussel2.ino | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/mussel2/mussel2.ino b/mussel2/mussel2.ino index 6ffb876..dc0a298 100644 --- a/mussel2/mussel2.ino +++ b/mussel2/mussel2.ino @@ -16,16 +16,20 @@ void setup() { } void loop() { - // Get second-long cyclic counter 0-11 - unsigned long currentTime = millis(); - unsigned long totalSeconds = currentTime / 1000; - unsigned long currentSecond = totalSeconds % 12; - String msg = "good"; - if (currentSecond >= 9) + if (read() >= 9) msg = "bad"; Serial.printf("*** NOTIFY: %s ***\n", msg); delay(1000); } + +byte read() { + // Get second-long cyclic counter 0-11 + unsigned long currentTime = millis(); + unsigned long totalSeconds = currentTime / 1000; + unsigned long currentSecond = totalSeconds % 12; + + return (byte)currentSecond; +} |