Arduino TimeLib Software Clock: Wiring, Code and Simulator

To build this Arduino TimeLib Software Clock project you need an Arduino Uno and nothing but the board itself. The Time library keeps calendar time from millis() and rolls over into the new year. Make the 0 connections in the wiring table, upload the Arduino C++ code, and set the time to 28 February 2028 and watch the leap day.

Open this circuit in the free Arduino Uno simulator

Parts list

QtyPartWhat it does
1Arduino Unothe microcontroller board

Wiring

No wiring: this project uses only the Arduino Uno.

Step by step

  1. Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
  2. Add the parts. Add nothing but the board itself from the parts palette.
  3. Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
  4. Run it. Press Run. Set the time to 28 February 2028 and watch the leap day.

Arduino C++ code

// Time (TimeLib): keep calendar time in software from millis().
#include <TimeLib.h>

void setup() {
  Serial.begin(9600);
  setTime(23, 59, 58, 31, 12, 2026);
}

void loop() {
  char line[24];
  snprintf(line, sizeof line, "%04d-%02d-%02d %02d:%02d:%02d", year(), month(), day(), hour(), minute(), second());
  Serial.println(line);
  delay(1000);
}

What to try

Set the time to 28 February 2028 and watch the leap day.

Frequently asked questions

How do I wire the TimeLib Software Clock project on an Arduino Uno?

No extra wiring is needed: it uses only the Arduino Uno itself.

What parts do I need for this Arduino project?

An Arduino Uno and nothing but the board itself.

Can I simulate this Arduino project online for free?

Yes. The BitForBytes Embedded Lab runs this exact circuit and Arduino C++ code in your browser for free, with no install and no hardware. The sketch is compiled with the real Arduino toolchain and runs on an emulated ATmega328P.

What does the code do?

The Time library keeps calendar time from millis() and rolls over into the new year.

More Arduino Uno projects