add fernbedienung example

This commit is contained in:
Anton Jacker 2024-06-13 15:59:51 +02:00
parent 76dee5d2b4
commit 159b6b239b
No known key found for this signature in database
GPG Key ID: 6581AFF52DAA87AC
2 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,25 @@
#include "Dezibot.h"
Dezibot dezibot = Dezibot();
void receivedCallback(String &msg) {
if (msg == "vorn") {
dezibot.motion.move();
} else if (msg == "links") {
dezibot.motion.rotateAntiClockwise();
} else if (msg == "rechts") {
dezibot.motion.rotateClockwise();
} else if (msg == "stop") {
dezibot.motion.stop();
}
}
void setup() {
dezibot.begin();
dezibot.communication.begin();
dezibot.communication.setGroupNumber(5);
dezibot.communication.onReceive(&receivedCallback);
}
void loop() {
}

View File

@ -0,0 +1,46 @@
#include "Dezibot.h"
Dezibot dezibot = Dezibot();
void setup() {
dezibot.begin();
dezibot.communication.begin();
dezibot.communication.setGroupNumber(5);
}
void loop() {
switch (dezibot.motionDetection.getTiltDirection()) {
case Front:
dezibot.multiColorLight.setTopLeds(GREEN);
dezibot.communication.sendMessage("vorn");
break;
case Left:
dezibot.multiColorLight.setTopLeds(YELLOW);
dezibot.communication.sendMessage("links");
break;
case Right:
dezibot.multiColorLight.setTopLeds(TURQUOISE);
dezibot.communication.sendMessage("rechts");
break;
case Back:
dezibot.multiColorLight.setTopLeds(BLUE);
dezibot.communication.sendMessage("stop");
break;
case Flipped:
dezibot.multiColorLight.setTopLeds(PINK);
dezibot.communication.sendMessage("stop");
break;
case Neutral:
dezibot.multiColorLight.turnOffLed();
dezibot.communication.sendMessage("stop");
break;
case Error:
dezibot.multiColorLight.setTopLeds(RED);
dezibot.communication.sendMessage("stop");
break;
}
delay(100);
}