aboutsummaryrefslogtreecommitdiff
path: root/mussel1
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2025-03-09 18:06:16 +0100
committerJonas Smedegaard <dr@jones.dk>2025-03-09 18:06:16 +0100
commit5c377e98a60e0761c853d7b8c5dec8afc3663ef6 (patch)
treedac37870136107a8a02d0ee67fad0a3a67c35e8b /mussel1
parent376b65cbef11511bf09f52376fd1b0d69ca6639e (diff)
rewrite more compactly
Diffstat (limited to 'mussel1')
-rw-r--r--mussel1/mussel1.ino22
1 files changed, 6 insertions, 16 deletions
diff --git a/mussel1/mussel1.ino b/mussel1/mussel1.ino
index 7165b98..e623798 100644
--- a/mussel1/mussel1.ino
+++ b/mussel1/mussel1.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() >= 50)
- msg = "bad";
-
- Serial.printf("*** NOTIFY: %s ***\n", msg);
+ Serial.printf("gap: %d\n", read());
delay(1000);
}
byte read() {
- // Get the current second (0-59)
- unsigned long currentTime = millis();
- unsigned long totalSeconds = currentTime / 1000;
- unsigned long currentSecond = totalSeconds % 60;
-
- return (byte)currentSecond;
+ // return 42 if current second modulo 60 is below 50, else 2
+ return (byte) (((unsigned long)millis() / 1000) % 60) < 50
+ ? 42
+ : 2;
}