Z Zh / Mbed 2 deprecated 3pi_Lab2_Task1

Dependencies:   mbed m3pi

Revision:
4:d53cb2045ee8
Parent:
3:1db119f74ecb
Child:
5:a7949ddab560
diff -r 1db119f74ecb -r d53cb2045ee8 main.cpp
--- a/main.cpp	Thu Jun 29 09:49:32 2017 +0000
+++ b/main.cpp	Tue Nov 19 10:27:17 2019 +0000
@@ -46,7 +46,7 @@
     float speed = 0.25;
 
     // threshold to determine when over line
-    float threshold = 0.2;
+    float threshold = 0.1;
 
     // value to increase/decrease speed by
     float power = 0.05;
@@ -61,21 +61,21 @@
         float position = robot.calc_line_position(values);
 
         // number is negative when the line is to the left. Need to turn left
-        if (position < threshold) {
+        if (position < -threshold) {
             // slow down left, speed up right
-
+            robot.motors(0,speed);
             // ADD CODE HERE TO CONTROL MOTORS
         }
         // number is positive when the line is to the right. Need to turn right
         else if (position > threshold) {
             // slow down right, speed up left
-
+            robot.motors(speed,0);
             // ADD CODE HERE TO CONTROL MOTORS
         }
         // else over the line
         else {
             // drive straight ahead
-
+            robot.motors(speed,speed);
             // ADD CODE HERE TO CONTROL MOTORS  
         }