Changed some file
This commit is contained in:
parent
e6e04254bc
commit
8b6aa55b95
|
|
@ -7,7 +7,6 @@
|
|||
// declare motors
|
||||
MeDCMotor _leftMotor(9);
|
||||
MeDCMotor _rightMotor(10);
|
||||
MeUltrasonicSensor ultrasonic(PORT_3);
|
||||
|
||||
// declare motor speeds
|
||||
int _leftMotorSpeed = 0;
|
||||
|
|
@ -23,38 +22,24 @@ void setup()
|
|||
|
||||
void loop()
|
||||
{
|
||||
double distance_in = ultrasonic.distanceInch();
|
||||
double distance_cm = ultrasonic.distanceCm();
|
||||
Serial.print("Distance: ");
|
||||
Serial.print(distance_cm);
|
||||
Serial.print(" cm | ");
|
||||
Serial.print(distance_in);
|
||||
Serial.println(" inches");
|
||||
|
||||
|
||||
// Move forward
|
||||
if (distance_cm > 20) {
|
||||
Serial.println("Move forward");
|
||||
move(1500, 1500, 100);
|
||||
} else{
|
||||
|
||||
// Move backwards
|
||||
Serial.println("Move backward");
|
||||
move(-100, -100, 500);
|
||||
|
||||
Serial.println("Turning right");
|
||||
move(100, -100, 500);
|
||||
|
||||
|
||||
delay(100);
|
||||
|
||||
// Turn right
|
||||
//Serial.println("Turn right");
|
||||
//move(100, -100, 2000);
|
||||
//Turn right
|
||||
Serial.println("Turn right");
|
||||
move(100, -100, 2000);
|
||||
}
|
||||
|
||||
// Turn left
|
||||
//Serial.println("Turn left");
|
||||
//move(-100, 100, 2000);
|
||||
Serial.println("Turn left");
|
||||
move(-100, 100, 2000);
|
||||
delay(100);
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue