Arduino elapsedMillis Non-Blocking Timing: Wiring, Code and Simulator

To build this Arduino elapsedMillis Non-Blocking Timing project you need an Arduino Uno and nothing but the board itself. A variable that counts up by itself, for non-blocking timing. Make the 0 connections in the wiring table, upload the Arduino C++ code, and use two elapsedMillis variables to blink two things at different rates.

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. Use two elapsedMillis variables to blink two things at different rates.

Arduino C++ code

// elapsedMillis: a variable that counts up by itself.
#include <elapsedMillis.h>

elapsedMillis since;
int seconds = 0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  if (since >= 1000) {
    since -= 1000;
    seconds++;
    Serial.print("Seconds: ");
    Serial.println(seconds);
  }
}

What to try

Use two elapsedMillis variables to blink two things at different rates.

Frequently asked questions

How do I wire the elapsedMillis Non-Blocking Timing 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?

A variable that counts up by itself, for non-blocking timing.

More Arduino Uno projects