Robot code for searching an object and charging at it.

Dependencies:   HCSR04 Motor mbed

Revision:
14:e639a42edf2e
Parent:
11:b45798cc3c10
Child:
17:47aa9ef2bec6
--- a/functions.cpp	Sat May 23 19:31:37 2015 +0000
+++ b/functions.cpp	Sat May 30 15:42:40 2015 +0000
@@ -128,14 +128,14 @@
         }
         // If fwd_back == 1 move forward or backwards
         if (fwd_bck == 1) {
-            printf("Moving forward\n");
-            printf("%d\n",fwd_bck);
             fwd = rand()%2;
             // If fwd == 1 move forward
             if  (fwd == 1) { 
+                printf("Moving forward\n");
                 move_detect(random_speed, fwd_bck, random_time);
             // If fwd == 0 move bacward
             } else {
+                printf("Moving bacwards\n");
                 move_detect(-random_speed, fwd_bck, random_time);
             }   
         // Turn
@@ -152,7 +152,7 @@
 }
 
 int detect_object(int range, float speed) {
-    // Start a timer - finds an object for 10 seconds
+    // Start a timer - finds an object for 5 seconds
     // if it doesn't find anything returns 0
     Timer usensor_t, inner_t;
     usensor_t.start();