aboutsummaryrefslogtreecommitdiff
path: root/mussel2/mussel2.ino
blob: dc0a298f1b6ad57604244282bff6241f92d0dede (plain)
  1. /// mussel2 - 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 DEVICE_NAME "Cycles of five good then one bad"
  6. void setup() {
  7. Serial.begin(115200);
  8. Serial.println();
  9. Serial.println("Initializing...");
  10. Serial.flush();
  11. Serial.printf("Device ready: %s",
  12. DEVICE_NAME);
  13. }
  14. void loop() {
  15. String msg = "good";
  16. if (read() >= 9)
  17. msg = "bad";
  18. Serial.printf("*** NOTIFY: %s ***\n", msg);
  19. delay(1000);
  20. }
  21. byte read() {
  22. // Get second-long cyclic counter 0-11
  23. unsigned long currentTime = millis();
  24. unsigned long totalSeconds = currentTime / 1000;
  25. unsigned long currentSecond = totalSeconds % 12;
  26. return (byte)currentSecond;
  27. }