Serial.print(dl);
Serial.print("
Serial.print(dr);
Serial.print("
Serial.println("Turning
status of the car and the value collected by the sensor*/
delay(300);
analogWrite(M1,0);
analogWrite(E1,0);
analogWrite(M2,0);
analogWrite(E2,0);/*As the car left after about 300ms stop, after measuring, 300ms
time car just can rotate about 90 degrees, because the DC motor does not like the steering
angle can be precisely controlled, so can only give a rough estimate, of course, different
motor speed is not Similarly, the time used is not the same, so everyone in the experiment
can be based on their own ideas, but the angle of 90, but also other values.*/
delay(1000);//************************************//Turning left
}
if
(dl
<=
38
&&
equal to 38 and the right value is less than or equal to 38, the following program in {} is
executed (dl <= 38, indicating that there is an obstacle on the left and dr<= 38 shows that
there is an obstacle on the right, so at this time the car is rotated 180 degrees backwards.
In the experiment, the car can just turn around 180 degrees after 500ms of rotation. Because
the DC motor can not precisely control the angle like the steering gear, An approximate value,
of course, different motor speed is not the same, the time used is not the same, so everyone
in the experiment can be based on the circumstances may be.)*/
analogWrite(M1, 255);
analogWrite(E1, 0);
analogWrite(M2, 0);
analogWrite(E2, 255);
Serial.print(dl);
Serial.print("
Serial.print(dr);
Serial.print("
Serial.println("Turning
status of the car and the value collected by the sensor.*/
delay(500);
analogWrite
analogWrite
analogWrite
analogWrite
delay(1000);//*********************************//Turning around
}
");
");
left");
dr
<= 38)
{/*If the value collected by the left sensor is less than or
//the speed value of motorA is 255
//the speed value of motorB is 255
");
");
around");/*Through the "Serial Monitor" print the current
(M1, 0);
(E1, 0);
(M2, 0);
(E2, 0);
/*Rotate 180 degrees and stop*/
/*Through the "Serial Monitor" print the current
50
Need help?
Do you have a question about the Hummer-Bot-1.0 and is the answer not in the manual?
Questions and answers