Roomba behavior
This commit is contained in:
parent
f5ec42e07c
commit
08a648efb5
|
|
@ -1,9 +1,27 @@
|
||||||
void setup() {
|
#include "MeMCore.h"
|
||||||
// put your setup code here, to run once:
|
|
||||||
|
|
||||||
|
MeDCMotor motor1(9);
|
||||||
|
|
||||||
|
MeDCMotor motor2(10);
|
||||||
|
|
||||||
|
MeUltrasonicSensor ultraSensor(PORT_3);
|
||||||
|
|
||||||
|
int minDistance = 15;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(9600);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue