Keywish Hummer-Bot-2.0 Instruction Manual page 75

Table of Contents

Advertisement

analogWrite(INPUT1_PIN, 0);
analogWrite(INPUT2_PIN, 0);
analogWrite(INPUT3_PIN, 0);
analogWrite(INPUT4_PIN, 0);
Serial.print("Distance =
Serial.print(da);
Serial.print("
Serial.println("Stopped");//If the distance is less than 20cm, the car stops and
outputs "stopped"
delay(500);
dl
= mUltrasonic.GetUltrasonicLeftDistance();
dr
= mUltrasonic.GetUltrasonicRightDistance();
Serial.print("Left distance =
Serial.print(dl);
Serial.print("
Serial.print("Right distance =
Serial.print(dr);
Serial.println("
//Head rudder turn right to measure the right distance and output
if
(dl
>=
20
&&
analogWrite(INPUT1_PIN, 0);
analogWrite(INPUT2_PIN, 255);
analogWrite(INPUT3_PIN, 0);
analogWrite(INPUT4_PIN, 255);
Serial.println("Turning
delay(200);
}
else if
(dr
analogWrite(INPUT1_PIN, 255);
analogWrite(INPUT2_PIN, 0);
analogWrite(INPUT3_PIN, 255);
analogWrite(INPUT4_PIN, 0);
Serial.println("Turning
delay(200);
}
else if
(dr
analogWrite(INPUT1_PIN, 255);
analogWrite(INPUT2_PIN, 0);
analogWrite(INPUT3_PIN, 0);
analogWrite(INPUT4_PIN, 255);
Serial.println("Turning
delay(700);
//If the left and right sides are less than 20cm, then turn around
}
}
}
//the speed value of motorA is 255
//the speed value of motorB is 255
");
");
");
");
");
");
dl
<=
1000
&&
dl
left1");
//To determine the left and right distance left if the larger
>=
20
&&
dr
<=
1000
//the speed value of motorA is 255
//the speed value of motorB is 255
right2");
//Judging the right and left distances
<=
20
&&
dl
<= 20) {
around");
> dr) {
&&
dr
> dl) {
72

Advertisement

Table of Contents
loading

Related Products for Keywish Hummer-Bot-2.0

Table of Contents