Keywish Hummer-Bot-2.0 Instruction Manual page 64

Table of Contents

Advertisement

/*Set a PWM value, the maximum value of PWM is 255, but the speed should not be too fast when
tracing the car, otherwise the car will shake more in the tracing process.*/
int
val
=
150
analogWrite(INPUT1_PIN, val);
analogWrite(INPUT2_PIN,
analogWrite(INPUT3_PIN, 0);
analogWrite(INPUT4_PIN, val);
}
else
if((right1
if the center > = 975 and left1 > = 975 are greater than 975, indicating that the middle and
left sensors did not detect the black line, right1 <= 8 shows the right sensor detects a black
line, then the car Has left to the left, or the black line has been turning to the right, so
the car should turn to the right. */
int
val
= 150;
analogWrite(INPUT1_PIN, val);
analogWrite(INPUT2_PIN, 0);
analogWrite(INPUT3_PIN, val);
analogWrite(INPUT4_PIN, 0);
}
else
if((right1
center > = 975 and right1 > = 975 are greater than 975, indicating that the middle and right
sensors did not detect the black line, left1 <= 8 shows that the left sensor detects the black
line, then the car Has been to the right deviation, or the black line has turned to the left,
so the car should turn left at this time. */
int
val
= 130;
analogWrite(INPUT1_PIN, 0);
analogWrite(INPUT2_PIN, val);
analogWrite(INPUT3_PIN, 0);
analogWrite(INPUT4_PIN, val);
}
if
((right1
== 0) &&
the center <= 8, left1 <= 8 and right1 <= 8 are greater than 8, indicating 3 sensors have
detected a black line, then the car has reached the "ten" intersection, because We have only 3
sensors, no way to make more sophisticated judgments, so only let the car choose to go
straight. */
int
val
= 130;
analogWrite(INPUT1_PIN, val);
analogWrite(INPUT2_PIN, 0);
analogWrite(INPUT3_PIN, 0);
analogWrite(INPUT4_PIN, val);
}
}
;
0
);
== 0) &&
(centre
== 1) &&
== 1) &&
(centre
== 1) &&
//the speed value of motorA is val
//the speed value of motorB is val
(centre
== 0) &&
//the speed value of motorA is val
//the speed value of motorB is val
(left1
== 1))
//the speed value of motorA is val
//the speed value of motorB is val
(left1
== 0))
(left1
== 0))
{/* The value collected to judge, if
//the speed value of motorA is val
//the speed value of motorB is val
61
{/* The value collected to judge,
{/* Judge the collected value, if

Advertisement

Table of Contents
loading

Related Products for Keywish Hummer-Bot-2.0

Table of Contents