Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save indefinit/fb095dddd28ca37cf7d004393c227f8d to your computer and use it in GitHub Desktop.
Arduino seconds counter
unsigned long lastTime = 0;
int seconds = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
if (millis() - lastTime >= 1000) {
seconds++;
lastTime = millis();
Serial.println(seconds);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment