75
head
.
write
(
90
);
/ * The servos swivel to 90 (center) during initialization, because
some servos may have errors, so they are not necessarily centered at 90 degrees, so be
fine-tuned where the servos are centered at 90 degrees. * /
delay
(
1000
);
}
void
loop
()
{
analogWrite
(
TrigPin
,
0
);
// Low high and low send a short pulse to TrigPin)
delayMicroseconds
(
2
);
analogWrite
(
TrigPin
,
255
);
delayMicroseconds
(
10
);
analogWrite
(
TrigPin
,
0
);
da
=
pulseIn
(
EchoPin
,
HIGH
)
/
58.0
;
// Convert the echo time to cm
if
(
da
>=
50
&&
da
<=
2000
)
/ * Judge the collected value, da> = 50 && da <= 2000,
meaning that when the distance between the current obstacle and the car is greater than
or equal to 50, and less than or equal to 2000cm, execute the following program in {} *
/
{
int
val
=
150
;
/ * When the straight line has a PWM value of 150, if the value is too
high, 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. * /
digitalWrite
(
M1
,
0
);
analogWrite
(
E1
,
val
);
//the speed value of motorA is val
digitalWrite
(
M2
,
0
);
analogWrite
(
E2
,
val
);
//the speed value of motorB is val
Serial
.
(
"Distance = "
);
Serial
.
(
da
);
Serial
.
(
" "
);
Serial
.
println
(
"Moving advance 50"
);
delay
(
500
);
/ * If the distance is more than 50cm, move forward and output "Moving
advance 50", indicating that the obstacle is more than 50cm from the car
}
if
(
da
<
40
&&
da
>
30
)
/ * Judge the collected value, da <50 && da> 30, meaning that
when the distance between the frontal obstacle and the car is greater than 30, and less
than 40cm, execute the following program in {} * /
{
int
val
=
130
;
Summary of Contents for Hummer-Bot
Page 1: ...Hummer Bot Instruction Manual Github https github com keywish keywish hummer bot...
Page 7: ...4...
Page 8: ...5...
Page 9: ...6...
Page 10: ...7...
Page 13: ...10 Fig 2 2 Several commonly usedArduino...
Page 15: ...12 After the completion as shown...
Page 16: ...13 The second step is to Welding wire on the motor...
Page 17: ...14 After the completion as shown...
Page 19: ...16 Fig 3 1 3 Diagram of Aluminum Alloy Bracket Installation...
Page 20: ...17 Fig 3 1 4 Diagram of Motor Installation Fig 3 1 5 Fixing Screw for Motor...
Page 24: ...21 Fig 3 1 10 Diagram of Wheel Installation Fig 3 1 10 Diagram of Wheel Screw Fixation...
Page 29: ...26 Fig 3 1 15 Diagram of Tracing Module Installation...
Page 30: ...27 Fig 3 1 16 Diagram of Screw Brackets Fig 3 1 17 The Back of Complete Installation...
Page 32: ...29 First install the screws on the UNO After the completion as shown...
Page 43: ...40 Fig 3 1 33 Diagram of Wires Arrangement Fig3 1 34 the Effect of Whole Assembly...
Page 56: ...53 Fig 3 2 11 Diagram of Data with Obstacles Fig 3 2 12 Diagram of Data without Obstacles...
Page 69: ...66 Fig 3 2 22 Diagram of Steering Gear Fig 3 2 23 Composition of Steering Gear...
Page 93: ...90 Fig 3 2 42 Receiving Head Position Fig 2 3 43 Installation of Receiving Head...