Julesnaps / Mbed 2 deprecated Linefollowproject

Dependencies:   m3pi mbed

Revision:
77:e1ece5800d7a
Parent:
76:4a6286ff0aee
Child:
78:0d905b656132
diff -r 4a6286ff0aee -r e1ece5800d7a main.cpp
--- a/main.cpp	Tue Oct 25 08:43:07 2022 +0000
+++ b/main.cpp	Tue Oct 25 08:58:07 2022 +0000
@@ -3,12 +3,14 @@
 #include <cstdio>
 
 m3pi m3pi;
+Timer timer;
 
-// DigitalOuts
+// DigitalOuts & Global Variabels
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
 DigitalOut led3(LED3);
 DigitalOut led4(LED4);
+int startTime;
 
 // Minimum and maximum motor speeds
 #define MAX 0.80
@@ -43,9 +45,14 @@
 void TE_LogVoltage(int count); // test funktion that write the woltage each time the battry is checked
 
 
+
+
 int main() {
     LocalFileSystem local("local"); 
-    
+    timer.start();
+    startTime = timer.read();
+
+
     /*Base program Variable initiation*/
     float right;
     float left;
@@ -195,11 +202,7 @@
     
     const float BATVOLTTRESHOLD = 0.5; // Treshold i volt
     int result = 0;
-    led4 = 1;
-    wait_ms (1);
-    led4 = 0;
-
-
+  
     /*Test if the voltage is below the threshold if so turn on go to pit mode*/
     if (m3pi.battery() <= BATVOLTTRESHOLD ){  
         result = 1; // Set goto pit condition
@@ -344,7 +347,7 @@
     FILE *fptr; /* voltagelog adres */
     fptr = fopen(VOLTAGELOGPATH,"a");
   
-    fprintf(fptr," %8d   ,   %4.4f   ,   %4.4f \n"  ,count, m3pi.battery(),m3pi.pot_voltage()  );
+    fprintf(fptr,"   %d    , %8d   ,   %4.4f   ,   %4.4f \n"  , timer.read()-startTime, count, m3pi.battery(),m3pi.pot_voltage()  );
     fclose(fptr);
 
 }
\ No newline at end of file