xerbot-arduino/examples/06-uno-minimal/06-uno-minimal.ino

9 lines
630 B
C++

// 06 · le plus petit : un Arduino Uno / Nano (AVR, 2 Ko de RAM). USB seulement ; une ligne de 128 caractères max.
#include <Xerbot.h>
Xerbot xb("uno", "capteur");
void commande(Xerbot& x, const XerbotCommande& c) {
if (strcmp(c.cmd, "led") == 0) { digitalWrite(13, c.booleen("on") ? HIGH : LOW); x.ack(c.id, true); } else x.ack(c.id, false);
}
void setup() { Serial.begin(115200); pinMode(13, OUTPUT); xb.battement(30000); xb.begin(Serial); xb.onCommande(commande); }
void loop() { xb.loop(); static unsigned long t = 0; if (millis() - t > 3000) { t = millis(); xb.telemetrie().add("a0", (long)analogRead(A0)).envoyer(); } }