![Keywish Hummer-Bot-1.0 Скачать руководство пользователя страница 54](http://html.mh-extra.com/html/keywish/hummer-bot-1-0/hummer-bot-1-0_instruction-manual_1962646054.webp)
51
if
(
dl
<=
38
&&
dr
>=
38
)
/*If the left sensor is less than or equal to 38 and the right
value is greater than or equal to 38, the following program in {} is executed (dl <= 38, indicating
that there is an obstacle on the left, dr> = 38 shows that there is no obstacle on the left,
so at this moment the car is turning to the side without obstacle, that is, turning to the
right)*/
{
analogWrite
(
M1
,
180
);
//the speed value of motorA is val
analogWrite
(
E1
,
0
);
analogWrite
(
M2
,
0
);
analogWrite
(
E2
,
180
);
//the speed value of motorA is val
Serial
.
(
dl
);
Serial
.
(
" "
);
Serial
.
(
dr
);
Serial
.
(
" "
);
Serial
.
println
(
"Turning right"
);
delay
(
300
);
analogWrite
(
M1
,
0
);
analogWrite
(
E1
,
0
);
analogWrite
(
M2
,
0
);
analogWrite
(
E2
,
0
);
/*Car must stop after each rotation, if you do not stop there will
be the phenomenon of rotating around. */
delay
(
1000
);
//*********************************Turning right
}
if
(
dl
>=
38
&&
dr
>=
38
)
{
/* Judge two values collected by the sensor. If the value collected
by the left sensor is greater than or equal to 38 and the right value is greater than or equal
to 38, execute the following program in {} (dl > = 38, indicating that there is no obstacle
on the left and dr > = 38 that there is no obstacle on the left, so the car at this time straight
*/
intval
=
150
;
/*When the straight line has a PWM value of 150, if the value is too
large, the speed of the car will be very fast, which may lead to the car can not hit the obstacle
in time when it encounters the obstacle. */
analogWrite
(
M1
,
0
);
analogWrite
(
E1
,
val
);
//the speed value of motorA is val
analogWrite
(
M2
,
0
);
analogWrite
(
E2
,
val
);
//the speed value of motorB is val
Serial
.
(
dl
);
Serial
.
(
" "
);
Serial
.
(
dr
);
Serial
.
(
" "
);
Serial
.
println
(
"go"
);
//**********************************/ / forward
}
}
Содержание Hummer-Bot-1.0
Страница 1: ...Hummer Bot 1 0 Instruction Manual V 2 0 ...
Страница 18: ...15 Step4 You need to install motors Figure 3 1 5 Schematic diagram of motor installation ...
Страница 50: ...47 Figure 3 2 15 Diagram of Data without Obstacles ...
Страница 83: ...80 Test code Path hummer bot Lesson ModuleDemo IrkeyPressed IrkeyPressed ino ...