Keywish Hummer-Bot Instruction Manual page 79

Table of Contents

Advertisement

digitalWrite(M1,0);
analogWrite(E1, val);
digitalWrite(M2,0);
analogWrite(E2, val);
Serial.print("Distance =
Serial.print(da);
Serial.print("
Serial.println("Moving
delay(500);
/ * If the distance is more than 40cm, move forward and output "Moving
advance 40", indicating that the obstacle is more than 40cm from the car
}
else if
(da
<= 20)
the current obstacle and the car is less than 20cm, execute the following program in
{}, the distance between the car and the obstacle has exceeded the safety value, So the
car stopped forward * /
{
int
val=0;
digitalWrite(M1,0);
analogWrite(E1, val);
digitalWrite(M2,0);
analogWrite(E2, val);
Serial.print("Distance =
Serial.print(da);
Serial.print("
Serial.println("Stopped");// If the distance is less than 20cm, the car will stop
and output "Stopped"
delay(500);
head.write(180);
left side of the car * /
delay(1000);
analogWrite(TrigPin, 0);
delayMicroseconds(2);
analogWrite(TrigPin, 255);
delayMicroseconds(10);
analogWrite(TrigPin, 0);
dl
= pulseIn(EchoPin, HIGH) / 58.0;
Serial.print("Left distance =
//the speed value of motorA is val
//the speed value of motorB is val
");
");
advance40");
/ * The collected value is judged, da <= 20, meaning that when
//the speed value of motorA is 0
//the speed value of motorB is 0
");
");
/ * Servo rotated 90 degrees from the original to 180 degrees, the
// Low high and low send a short pulse to TrigPin
");
// Convert the echo time to cm
76

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Hummer-Bot and is the answer not in the manual?

Related Products for Keywish Hummer-Bot

Table of Contents

Save PDF