der Roboter / S1

Dependencies:   SensoryTest

Fork of btbee by Nikolas Goldin

Files at this revision

API Documentation at this revision

Comitter:
mmpeter
Date:
Tue May 20 14:33:23 2014 +0000
Parent:
9:6ae4359b73df
Child:
11:45172e28ecb2
Commit message:
testing

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue May 20 13:53:38 2014 +0000
+++ b/main.cpp	Tue May 20 14:33:23 2014 +0000
@@ -7,31 +7,34 @@
 int main() {
     
     float speed = 0.1;
-    float threshold = 0.1;
+    float correction = 0.5;
+    float threshold = 0.5;
     
     thinggy.locate(0,1);
     thinggy.printf("Line Flw");
     
-    wait(2.0);
+    wait(1.0);
     
     thinggy.sensor_auto_calibrate();
     while(1) {
          // -1.0 is far left, 1.0 is far right, 0.0 in the middle
         float position= thinggy.line_position();
  
-        // Line is more than the threshold to the right, slow the left motor
+        // Too far to the right--slow left motor
         if (position > threshold) {
-            thinggy.right(speed);
+            thinggy.right_motor(speed);
+            thinggy.left_motor(speed-correction);
             
         }
  
-        // Line is more than 50% to the left, slow the right motor
+        // Too far to the left--slow right motor
         else if (position < -threshold) {
             thinggy.left_motor(speed);
+            thinggy.right_motor(speed-correction);
             
         }
  
-        // Line is in the middle
+        // Default: Centered
         else {
             thinggy.forward(speed);
         }