Created
March 24, 2026 18:49
-
-
Save indefinit/c436ec5feec89e4a45a9ea6917863fcd to your computer and use it in GitHub Desktop.
Arduino onboard LED minute/second timer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| unsigned long lastTime = 0; | |
| int seconds = 0; | |
| int minutes = 0; | |
| void setup() { | |
| Serial.begin(9600); | |
| pinMode(LED_BUILTIN, OUTPUT); | |
| } | |
| void loop() { | |
| if (millis() - lastTime >= 1000) { | |
| lastTime = millis(); | |
| seconds++; | |
| if (seconds >= 60) { | |
| seconds = 0; | |
| minutes++; | |
| // Long flash to signal a new minute | |
| digitalWrite(LED_BUILTIN, HIGH); | |
| delay(500); | |
| digitalWrite(LED_BUILTIN, LOW); | |
| } else { | |
| // Short blink every second | |
| digitalWrite(LED_BUILTIN, HIGH); | |
| delay(50); | |
| digitalWrite(LED_BUILTIN, LOW); | |
| } | |
| Serial.print(minutes); | |
| Serial.print("m "); | |
| Serial.print(seconds); | |
| Serial.println("s"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment