xerbot 0.1.0 : le contrat xerbot v1 pour Arduino / PlatformIO (USB, ESP-NOW, Bluetooth), 6 exemples dont RuView CSI, test natif 8/8
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R75H65SynGwRG5vBSoYeZ1
This commit is contained in:
16
examples/01-usb-capteur/01-usb-capteur.ino
Normal file
16
examples/01-usb-capteur/01-usb-capteur.ino
Normal file
@@ -0,0 +1,16 @@
|
||||
// 01 · un capteur en USB (n'importe quelle carte Arduino : ESP32, ESP8266, Pico, Uno…)
|
||||
// Branche en USB, ouvre le ploxion xerbot › ⌁ trouver › ⎍ USB : « cube-capteur » apparaît, sa télémétrie arrive, « ◎ ping » répond.
|
||||
#include <Xerbot.h>
|
||||
Xerbot xb("cube-capteur", "capteur");
|
||||
const int LED = LED_BUILTIN;
|
||||
|
||||
void commande(Xerbot& x, const XerbotCommande& c) {
|
||||
if (strcmp(c.cmd, "led") == 0) { digitalWrite(LED, c.booleen("on") ? HIGH : LOW); x.ack(c.id, true); }
|
||||
else x.ack(c.id, false, "commande inconnue");
|
||||
}
|
||||
void setup() { Serial.begin(115200); pinMode(LED, OUTPUT); xb.begin(Serial); xb.onCommande(commande); }
|
||||
void loop() {
|
||||
xb.loop();
|
||||
static unsigned long t = 0;
|
||||
if (millis() - t > 2000) { t = millis(); xb.telemetrie().add("a0", (long)analogRead(A0)).add("uptime_s", (long)(millis() / 1000)).envoyer(); }
|
||||
}
|
||||
Reference in New Issue
Block a user