//} else { md.setM2Speed(-180); // Left motor back } if (Bump_Left == || == { HIGH Bump_Right HIGH) md.setM2Speed(-150); // Left motor stop md.setM1Speed(-150); // Right motor stop delay(1500); if ((int)infraredDistance %2 == { 1) md.setM2Speed(200); md.setM1Speed(-200); delay(1250); } else { md.setM2Speed(-200); md.setM1Speed(200); delay(1250); } } if ((Sonar_Left) < && (Sonar_Right) < || < ) { 8 8 infraredDistance 7 // Obstacles to right and left; stop. // Reverse md.setM2Speed(-200); // Left motor stop md.setM1Speed(-200); // Right motor stop delay(2000); // Wait 200 ms and check again // if (target_found == 'c'){ // md.setM1Speed(0); // md.setM2Speed(0); // delay(10000); // } if ((int)infraredDistance %2 == { 1) md.setM2Speed(200); md.setM1Speed(-200); delay(1250); } else { md.setM2Speed(-200); md.setM1Speed(200); delay(1250); } } delay(100); // Main loop is 100 ms (10 Hz) } /*** Target has been found with IP camera ***/ void approachTarget(){ // user by updating LCD lcd.clear(); lcd.setCursor(0,0); lcd.print("Approaching Target"); md.setM2Speed(0); // Stop both motors md.setM1Speed(0); delay(2000); // Wait 2 seconds before approaching
//} else { md.setM2Speed(-180); // Left motor back } if (Bump_Left == HIGH || Bump_Right == HIGH) { md.setM2Speed(-150); // Left motor stop md.setM1Speed(-150); // Right motor stop delay(1500); if ((int)infraredDistance %2 == 1) { md.setM2Speed(200); md.setM1Speed(-200); delay(1250); } else { md.setM2Speed(-200); md.setM1Speed(200); delay(1250); } } if ((Sonar_Left) < 8 && (Sonar_Right) < 8 || infraredDistance < 7 ) { // Obstacles to right and left; stop. // Reverse md.setM2Speed(-200); // Left motor stop md.setM1Speed(-200); // Right motor stop delay(2000); // Wait 200 ms and check again // if (target_found == 'c'){ // md.setM1Speed(0); // md.setM2Speed(0); // delay(10000); // } if ((int)infraredDistance %2 == 1) { md.setM2Speed(200); md.setM1Speed(-200); delay(1250); } else { md.setM2Speed(-200); md.setM1Speed(200); delay(1250); } } delay(100); // Main loop is 100 ms (10 Hz) } /*** Target has been found with IP camera ***/ void approachTarget(){ // user by updating LCD lcd.clear(); lcd.setCursor(0,0); lcd.print("Approaching Target"); md.setM2Speed(0); // Stop both motors md.setM1Speed(0); delay(2000); // Wait 2 seconds before approaching