diff options
author | Jonas Smedegaard <dr@jones.dk> | 2025-03-09 18:06:16 +0100 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2025-03-09 18:06:16 +0100 |
commit | 5c377e98a60e0761c853d7b8c5dec8afc3663ef6 (patch) | |
tree | dac37870136107a8a02d0ee67fad0a3a67c35e8b /mussel2 | |
parent | 376b65cbef11511bf09f52376fd1b0d69ca6639e (diff) |
rewrite more compactly
Diffstat (limited to 'mussel2')
-rw-r--r-- | mussel2/mussel2.ino | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/mussel2/mussel2.ino b/mussel2/mussel2.ino index 652758a..9e41448 100644 --- a/mussel2/mussel2.ino +++ b/mussel2/mussel2.ino @@ -7,29 +7,19 @@ void setup() { Serial.begin(115200); - Serial.println(); - Serial.println("Initializing..."); - Serial.flush(); - - Serial.printf("Device ready: %s", + Serial.printf("\n\nDevice ready: %s\n", MUSSEL_ATTITUDE); } void loop() { - String msg = "good"; - if (read() >= 9) - msg = "bad"; - - Serial.printf("*** NOTIFY: %s ***\n", msg); + Serial.printf("gap: %d\n", read()); 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; + // return 42 if current second modulo 12 is below 9, else 2 + return (byte) (((unsigned long)millis() / 1000) % 12) < 9 + ? 42 + : 2; } |