Skip to content

Instantly share code, notes, and snippets.

@indefinit
Created March 24, 2026 18:49
Show Gist options
  • Select an option

  • Save indefinit/c436ec5feec89e4a45a9ea6917863fcd to your computer and use it in GitHub Desktop.

Select an option

Save indefinit/c436ec5feec89e4a45a9ea6917863fcd to your computer and use it in GitHub Desktop.
Arduino onboard LED minute/second timer
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