Roomba behavior

This commit is contained in:
Lucas Marais 2023-03-31 09:30:35 +02:00
parent f5ec42e07c
commit 08a648efb5
1 changed files with 21 additions and 3 deletions

View File

@ -1,9 +1,27 @@
void setup() {
// put your setup code here, to run once:
#include "MeMCore.h"
MeDCMotor motor1(9);
MeDCMotor motor2(10);
MeUltrasonicSensor ultraSensor(PORT_3);
int minDistance = 15;
void setup() {
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if (ultraSensor.distanceCm()<minDistance){
motor1.run(100);
motor2.run(100);
delay(800);
}
else {
motor1.run(-155);
motor2.run(155);
}
}