ArduinoArduino UnoExact chip

Stopwatch (TM1637)

TM1637Display counts minutes and seconds, the colon blinking each second.

Stopwatch (TM1637) in Argynix Lab

The code

sketch.inoC++
// A TM1637 4-digit display on two pins (CLK 2, DIO 3): minutes and seconds since
// the sketch started, the colon on for half of each second.
#include <TM1637Display.h>

TM1637Display display(2, 3);

void setup() {
  display.setBrightness(5);
  display.clear();
}

void loop() {
  unsigned long ms = millis();
  int seconds = (ms / 1000) % 60;
  int minutes = (ms / 60000) % 100;
  bool colon = (ms % 1000) < 500;
  display.showNumberDecEx(minutes * 100 + seconds, colon ? 0b01000000 : 0, true);
  delay(50);
}