Merged Tiltdetection

This commit is contained in:
hhaupt
2024-06-13 00:57:32 +02:00
5 changed files with 252 additions and 15 deletions

View File

@ -0,0 +1,19 @@
#include "Dezibot.h"
Dezibot dezibot = Dezibot();
void setup() {
// put your setup code here, to run once:
dezibot.begin();
dezibot.multiColorLight.turnOffLed();
}
void loop() {
// put your main code here, to run repeatedly:
if(dezibot.motionDetection.isShaken(1000,zAxis)){
dezibot.multiColorLight.setTopLeds(0xFF0000);
} else if(dezibot.motionDetection.isShaken(1000,xAxis|yAxis)) {
dezibot.multiColorLight.setTopLeds(0x00FF00);
}
}

View File

@ -0,0 +1,37 @@
#include "Dezibot.h"
Dezibot dezibot = Dezibot();
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
dezibot.begin();
}
void loop() {
switch (dezibot.motionDetection.getTiltDirection()) {
case Front:
dezibot.multiColorLight.setTopLeds(GREEN);
break;
case Left:
dezibot.multiColorLight.setTopLeds(YELLOW);
break;
case Right:
dezibot.multiColorLight.setTopLeds(TURQUOISE);
break;
case Back:
dezibot.multiColorLight.setTopLeds(BLUE);
break;
case Flipped:
dezibot.multiColorLight.setTopLeds(PINK);
break;
case Neutral:
dezibot.multiColorLight.turnOffLed();
break;
case Error:
dezibot.multiColorLight.setTopLeds(RED);
break;
}
delay(100);
}