aboutsummaryrefslogtreecommitdiff
path: root/mussel1/mussel1.ino
blob: 7165b983f20871b2668328b1678b814a132c72a9 (plain)
  1. /// mussel1 - mussel voter influenced by time
  2. ///
  3. /// SPDX-License-Identifier: GPL-3.0-or-later
  4. /// SPDX-FileCopyrightText: 2025 Jonas Smedegaard <dr@jones.dk>
  5. #define MUSSEL_ATTITUDE "closed 10 seconds every 50 seconds"
  6. void setup() {
  7. Serial.begin(115200);
  8. Serial.println();
  9. Serial.println("Initializing...");
  10. Serial.flush();
  11. Serial.printf("Device ready: %s",
  12. MUSSEL_ATTITUDE);
  13. }
  14. void loop() {
  15. String msg = "good";
  16. if (read() >= 50)
  17. msg = "bad";
  18. Serial.printf("*** NOTIFY: %s ***\n", msg);
  19. delay(1000);
  20. }
  21. byte read() {
  22. // Get the current second (0-59)
  23. unsigned long currentTime = millis();
  24. unsigned long totalSeconds = currentTime / 1000;
  25. unsigned long currentSecond = totalSeconds % 60;
  26. return (byte)currentSecond;
  27. }