Robot code for searching an object and charging at it.

Dependencies:   HCSR04 Motor mbed

Files at this revision

API Documentation at this revision

Comitter:
lhartfield
Date:
Sun Jun 07 15:03:54 2015 +0000
Parent:
20:37a89edd1cde
Child:
23:07b3c12800a6
Commit message:
Changed function name from moverandom to move_random for consistency. Parameterized move_random().

Changed in this revision

functions.cpp Show annotated file Show diff for this revision Revisions of this file
functions.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/functions.cpp	Sun Jun 07 14:18:00 2015 +0000
+++ b/functions.cpp	Sun Jun 07 15:03:54 2015 +0000
@@ -145,7 +145,7 @@
     MotorRight.speed(speed);
 }
 
-void moverandom()
+void move_random(float speed)
 {
     int counter;
     int fwd_bck;
@@ -167,16 +167,16 @@
             // If fwd == 1 move forward
             if  (fwd == 1) { 
                 printf("Moving forward\n");
-                move_detect(move_forwardspeed, fwd_bck, random_time);
+                move_detect(speed, fwd_bck, random_time);
             // If fwd == 0 move bacward
             } else {
                 printf("Moving bacwards\n");
-                move_detect(-move_forwardspeed, fwd_bck, random_time);
+                move_detect(speed, fwd_bck, random_time);
             }   
         // Turn
         } else {
             printf("Turning\n");
-            move_detect(move_forwardspeed, fwd_bck, random_time);
+            move_detect(speed, fwd_bck, random_time);
         }
     }
 }
--- a/functions.h	Sun Jun 07 14:18:00 2015 +0000
+++ b/functions.h	Sun Jun 07 15:03:54 2015 +0000
@@ -16,7 +16,7 @@
 int read_line1();
 int read_line2();
 int detect_line();
-void moverandom();
+void move_random(float speed=move_forwardspeed);
 void reverse(float speed);
 void turn(float speed);
 void reverseandturn(float speed);
--- a/main.cpp	Sun Jun 07 14:18:00 2015 +0000
+++ b/main.cpp	Sun Jun 07 15:03:54 2015 +0000
@@ -120,7 +120,7 @@
 
         } else {
 
-            moverandom();
+            move_random();
 
         }