Keywish Hummer-Bot-2.0 Instruction Manual page 74

Table of Contents

Advertisement

mUltrasonic.SetServoDegree(90);
delay(1000);
}
void
loop() {
left
= digitalRead(leftPin);
right
= digitalRead(rightPin);
da
= mUltrasonic.GetUltrasonicFrontDistance();
if
((da
>= 50) &&
int
val
= 150;
analogWrite(INPUT1_PIN,
analogWrite(INPUT2_PIN, 0);
analogWrite(INPUT3_PIN, 0);
analogWrite(INPUT4_PIN, val);
Serial.print("Distance =
Serial.print(da);
Serial.print("
Serial.println("Moving advance
// delay(500);
output "is moving forward"
}
else if
((left
analogWrite(INPUT1_PIN, 200);
analogWrite(INPUT2_PIN, 0);
analogWrite(INPUT3_PIN, 0);
analogWrite(INPUT4_PIN, 130);
Serial.println("Turning
delay(200);
analogWrite(INPUT1_PIN, 0);
analogWrite(INPUT2_PIN, 0);
analogWrite(INPUT3_PIN, 0);
analogWrite(INPUT4_PIN, 0);
//delay(1000); //********************************************//Turning right
}
else if
((left
analogWrite(INPUT1_PIN,
analogWrite(INPUT2_PIN, 0);
analogWrite(INPUT3_PIN, 0);
analogWrite(INPUT4_PIN, 200);
Serial.println("Turning
delay(200);
analogWrite(INPUT1_PIN, 0);
analogWrite(INPUT2_PIN, 0);
analogWrite(INPUT3_PIN, 0);
analogWrite(INPUT4_PIN, 0);
// delay(1000); //********************************************//Turning left
}
else if
(da
<= 25) {
(da
<= 2000) &&
(left
val);//the speed value of motorA is 255
//the speed value of motorB is 255
");
");
50");
//If the distance is greater than 20cm then go forward and
== 0) &&
(right
!= 0) &&
//the speed value of motorA is val
//the speed value of motorA is val
right");
!= 0) &&
(right
== 0) &&
130);//the speed value of motorA is 200
//the speed value of motorB is 200
left");
!= 0) &&
(right
!= 0)) {
da
>= 30) {
da
>=
30
) {
71

Advertisement

Table of Contents
loading

Related Products for Keywish Hummer-Bot-2.0

Table of Contents