Robot code for searching an object and charging at it.

Dependencies:   HCSR04 Motor mbed

Revision:
27:96a0ff2f474c
Parent:
26:5ee2a32949e6
Child:
30:8a5570b2de68
--- a/functions.cpp	Sun Jun 07 16:36:03 2015 +0000
+++ b/functions.cpp	Sun Jun 07 17:30:06 2015 +0000
@@ -252,14 +252,14 @@
     return sense;
 }
 
-void move_detect(float speed, int fwd_bck, int time) {
+void move_detect(float speed, int fwd_bck, int time, int wait) {
     Timer t;
     t.start();
     int detect = 0;
     
     if(fwd_bck == 1) {
         move_forward(speed);
-        wait_ms(500);
+        wait_ms(wait);
     } else {
         turn(speed + 0.2);
     }
@@ -270,14 +270,14 @@
         if(detect == 1) {
             stop();
             turn_leds_on();
-            move_detect(-moveforwardspeed,1,1000);
+            move_detect(-moveforwardspeed,1,1000,300);
             stop();
             break;
         // If line is detected from back just keep on moving forward
         } else if (detect == -1) {
             stop();
             turn_leds_on();
-            move_detect(moveforwardspeed,1,1000);
+            move_detect(moveforwardspeed,1,1000,300);
             stop();
             break;
         }