With Libraries

Dependencies:   btbee m3pi_ng mbed FatFileSystem MSCFileSystem

Files at this revision

API Documentation at this revision

Comitter:
charwhit
Date:
Fri May 29 13:37:39 2015 +0000
Parent:
10:83dfbc5e93ed
Child:
12:0422156f83f6
Commit message:
Essentially finished working code

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri May 29 11:55:50 2015 +0000
+++ b/main.cpp	Fri May 29 13:37:39 2015 +0000
@@ -1,4 +1,4 @@
-#include "mbed.h"
+#include =-pokm rtfg"mbed.h"
 #include "MSCFileSystem.h"
 #include "btbee.h"
 #include "m3pi_ng.h"
@@ -17,7 +17,7 @@
 DigitalIn m3pi_IN[]= {(p12),(p21)}; // IR sensor and Knopf
 Timer timer;
 Timer time_wait;
-#define MAX .5
+#define MAX .15
 #define MIN 0
 
 //#define P_TERM 5
@@ -28,9 +28,9 @@
 
 int main()
 {
-    float P_TERM = 2.5;
-    float I_TERM = .5;
-    float D_TERM = 20;
+    float P_TERM = 1;
+    float I_TERM = 0;
+    float D_TERM = 0;
 
     btbee.reset();
     robot.sensor_auto_calibrate();
@@ -94,8 +94,8 @@
 
         //else if (m3pi_IN [0] == 0)
         //{break;}
-
-        if( x[0] > 300 && x[2]>300 && x[4]>300 & !passed) {
+       
+        if( (x[0] > 300 && x[2]>300 && x[4]>300 & !passed) || timer.read() > 5) {
             if (lap == 0) {
                 /*while( x[0]> 300 && x[4] > 300) {
                     robot.calibrated_sensor(x);
@@ -104,17 +104,17 @@
                 lap= lap +1;
             }
 
-            else if (lap == 1) {
+            else if (lap == 1 || timer.read() > 5) {
                 robot.stop();
                 robot.printf("Size: %d", rightval.size());
-                //if(myFile.is_open()){
+                if(fp != NULL){
                     for (int i = 0; i < rightval.size(); ++i)
                         fprintf(fp,"%f %f %f\n",leftval[i], rightval[i], lineposval[i]);
                     fclose(fp);
                     robot.cls();
                     robot.locate(0,0);
                     robot.printf("Doner");
-                //}
+                }
                 lap_time = timer.read();
                 total_time += lap_time;
                 average_time = total_time/lap;
@@ -155,7 +155,7 @@
                 total_time += lap_time;
                 average_time = total_time/lap;
                 lap = lap +1;
-                timer.reset();
+                //timer.reset();
             }
             passed = true;
         }