mirror of
https://gitlab.dit.htwk-leipzig.de/phillip.kuehne/dezibot.git
synced 2025-05-21 20:11:46 +02:00
add fernbedienung example
This commit is contained in:
parent
76dee5d2b4
commit
159b6b239b
25
example/Fernbedienung/empfaenger/empfaenger.ino
Normal file
25
example/Fernbedienung/empfaenger/empfaenger.ino
Normal 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() {
|
||||||
|
}
|
46
example/Fernbedienung/sender/sender.ino
Normal file
46
example/Fernbedienung/sender/sender.ino
Normal 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);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user