first basic but working version of fiend a friend

This commit is contained in:
hhaupt 2024-04-28 23:11:08 +02:00
parent 53ba11839f
commit 9314683201

View File

@ -1,7 +1,7 @@
#include "Dezibot.h" #include "Dezibot.h"
Dezibot dezibot = Dezibot(); Dezibot dezibot = Dezibot();
const int centeredThreshold = 100; const int centeredThreshold = 50 ;
void setup() { void setup() {
// put your setup code here, to run once: // put your setup code here, to run once:
@ -17,29 +17,29 @@ void loop() {
//correct Stearing to be centered //correct Stearing to be centered
if( abs(leftValue-rightValue) if( abs(leftValue-rightValue)
< centeredThreshold){ < centeredThreshold){
dezibot.motion.move(1); dezibot.motion.move();
}else{ }else{
if (leftValue > rightValue){ if (leftValue > rightValue){
dezibot.motion.rotateAnticlockwise(1); dezibot.motion.rotateAntiClockwise();
} else{ } else{
dezibot.motion.rotateClockwise(1); dezibot.motion.rotateClockwise();
} }
} }
dezibot.multiColorLight.setTopLeds(BLUE); dezibot.multiColorLight.setTopLeds(BLUE);
break; break;
case IR_LEFT: case IR_LEFT:
dezibot.motion.rotateAnticlockwise(1); dezibot.motion.rotateAntiClockwise();
dezibot.multiColorLight.setTopLeds(RED); dezibot.multiColorLight.setTopLeds(RED);
break; break;
case IR_RIGHT: case IR_RIGHT:
dezibot.motion.rotateClockwise(1); dezibot.motion.rotateClockwise();
dezibot.multiColorLight.setTopLeds(GREEN); dezibot.multiColorLight.setTopLeds(GREEN);
break; break;
case IR_BACK: case IR_BACK:
if(leftValue > rightValue){ if(leftValue > rightValue){
dezibot.motion.rotateAnticlockwise(1); dezibot.motion.rotateAntiClockwise();
} else { } else {
dezibot.motion.rotateClockwise(1); dezibot.motion.rotateClockwise();
} }
dezibot.multiColorLight.setTopLeds(YELLOW); dezibot.multiColorLight.setTopLeds(YELLOW);
break; break;