From 080563f6cc14fd3f14122f4fad045fd6d9e7feee Mon Sep 17 00:00:00 2001 From: hhaupt Date: Tue, 11 Jun 2024 20:14:56 +0200 Subject: [PATCH] added example for tiltdetection --- .../tilt_detection/tilt_detection.ino | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 example/IMU/Tilt_Detection/tilt_detection/tilt_detection.ino diff --git a/example/IMU/Tilt_Detection/tilt_detection/tilt_detection.ino b/example/IMU/Tilt_Detection/tilt_detection/tilt_detection.ino new file mode 100644 index 0000000..c9de988 --- /dev/null +++ b/example/IMU/Tilt_Detection/tilt_detection/tilt_detection.ino @@ -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); +}