Library for using the xbee-compatible Bluetooth Bee Module on an m3pi.

Dependencies:   SensoryTest

Fork of btbee by Nikolas Goldin

Files at this revision

API Documentation at this revision

Comitter:
mmpeter
Date:
Wed May 21 15:00:52 2014 +0000
Parent:
17:a6cb4c42308c
Commit message:
Turnarounds

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r a6cb4c42308c -r eddba761c425 main.cpp
--- a/main.cpp	Wed May 21 14:42:33 2014 +0000
+++ b/main.cpp	Wed May 21 15:00:52 2014 +0000
@@ -5,10 +5,6 @@
 
 using namespace std;
 
-void turn_around(int array[5],float speed);
-
-int sensor_refresh(m3pi thinggy, int sensor[5], int x);
-
 m3pi thinggy;
 
 
@@ -29,31 +25,29 @@
     thinggy.sensor_auto_calibrate();
  
     thinggy.calibrated_sensor(sensor);
-    returned = sensor[2];
-    thinggy.cls();
-    thinggy.print("Apple",5);
+    returned = (sensor[1] + sensor[2] + sensor[3])/3;
+
     
     
     while(1) {
-        thinggy.print("Apfel",5);
         // change "if" to while
-        while(returned < 200){
+        while(returned < 220){
                 while(sensor[0] < sensor[4]){
-                    thinggy.left_motor(speed);
-                    thinggy.right_motor(-speed);
+                    thinggy.left_motor(.1);
+                    thinggy.right_motor(-.1);
                     thinggy.calibrated_sensor(sensor);
                 }
                 while(sensor[4] > sensor[0]){
-                    thinggy.left_motor(-speed);
-                    thinggy.right_motor(speed);
+                    thinggy.left_motor(-.1);
+                    thinggy.right_motor(.1);
                     thinggy.calibrated_sensor(sensor);
                 }
                 thinggy.calibrated_sensor(sensor);
-                returned = sensor[2];
+                returned = (sensor[1] + sensor[2] + sensor[3])/3;
         }
         
-        // change "if" to while    
-        while(returned > 200){
+        // Curves and straightaways    
+        while(returned > 220){
  
         float position = thinggy.line_position();
         correction = k*(position);
@@ -76,10 +70,10 @@
             thinggy.left_motor(speed-correction);
         }
          thinggy.calibrated_sensor(sensor);
-         returned = sensor[2];   
+         returned = (sensor[1] + sensor[2] + sensor[3])/3;   
         }
     thinggy.calibrated_sensor(sensor);
-    returned = sensor[2];
+    returned = (sensor[1] + sensor[2] + sensor[3])/3;
     }
 }