Robot code for searching an object and charging at it.

Dependencies:   HCSR04 Motor mbed

Revision:
26:5ee2a32949e6
Parent:
25:7662e93a77eb
Child:
27:96a0ff2f474c
Child:
28:71781431b010
--- a/main.cpp	Sun Jun 07 15:17:02 2015 +0000
+++ b/main.cpp	Sun Jun 07 16:36:03 2015 +0000
@@ -91,7 +91,8 @@
 
     while(true) {
         // Sample code to detect and object and move_forward at it
-
+        wait(1);
+        
         detect_o = detect_object(range, searchspeed);
 
         if (detect_o == 1) {
@@ -104,19 +105,12 @@
                 // If line is detected from front then reverse
                 if(detect_l == 1) {
                     stop();
-                    turn_leds_on();
+                    turn_led_right();
                     reverse(searchspeed);
                     wait(1.5);
                     detect_l = 0;
                     break;
                 // If line is detected from back just keep on moving forward
-                } else if (detect_l == -1) {
-                    stop();
-                    turn_leds_on();
-                    move_forward(searchspeed);
-                    wait(1.5);
-                    detect_l = 0;
-                    break;
                 }
             }