A little curiosity. A whole lot of making.Robotics, CNC & connected ideas
robodatech.
Arduino sample library

Millis Scheduler 19

Run non-blocking timed jobs without delay-heavy loops.

Open in compiler →
/*
  Roboda verified Arduino sample 0463
  Feature: Millis Scheduler
  Generated for online build, classroom practice, and hardware upload testing.
*/

unsigned long lastBlink = 0;
unsigned long lastReport = 0;
const unsigned long blinkEvery = 290;

void setup() {
  pinMode(13, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  unsigned long now = millis();
  if (now - lastBlink >= blinkEvery) {
    lastBlink = now;
    digitalWrite(13, !digitalRead(13));
  }
  if (now - lastReport >= 1000) {
    lastReport = now;
    Serial.println(now);
  }
}

How it works

Practice this Arduino feature with a verified Roboda sketch.

  1. Read the constants at the top of the sketch.
  2. Wire the pins exactly as listed in the pin map.
  3. Upload or compile once before changing values.
  4. Change one value at a time and watch Serial Monitor or the output device.

Connections

PinConnect toNote
D13Built-in LEDDemonstrates timing without blocking delay().

Good ideas start here.

Robotics lessons, build notes and useful updates. Subscribe by entering your email.