Skip to main content

C++ (Arduino) API

The @blokdots/arduino-cpp framework is included in every exported Arduino sketch via a single include:

C++
#include "blokdots.h"

#Sketch Lifecycle

Every exported sketch follows this pattern:

C++
#include "blokdots.h"

// Component instances (e.g. Led led(5); Button button(2);)

void setup() {
  blokdots::beginAll();   // initialize all registered components

  // subscribe to events
  eventBus.on(MY_EVENT, myHandler, nullptr);
}

void loop() {
  eventBus.tick();        // run event system + timers
  blokdots::tickAll();    // update all component animations
}

#Core Modules

ModuleDescription
CoreValue types (String, Color), beginAll(), tickAll(), start(), stop()
EventBusEvent system with on(), emit(), timers (setTimeout, setInterval)

#Base Component Classes

ClassUse for
DigitalActorDigital outputs (LED, relay, electromagnet)
AnalogSensorAnalog inputs (brightness, potentiometer)
AnalogActorPWM outputs (dimmable LED, vibration motor)
ButtonDigital inputs with debouncing and hold detection