Julesnaps / Mbed 2 deprecated Linefollowproject

Dependencies:   m3pi mbed

Revision:
5:dbd32cb3650a
Parent:
4:803dc29393cc
Child:
6:6865930c1135
--- a/main.cpp	Tue Oct 04 11:51:10 2022 +0000
+++ b/main.cpp	Tue Oct 04 11:58:03 2022 +0000
@@ -13,25 +13,15 @@
 #define I_TERM 0
 #define D_TERM 20
 
+// Tresholds 
+#define BATVOLTRESHOLD 3.0
+
 int main() {
-    float a=m3pi.battery();
-    float b=m3pi.pot_voltage();
-    m3pi.locate(0,0);
-    
-       
-    m3pi.cls();
-    m3pi.printf("%f.3 ",a);
-    m3pi.locate(0,1);
-    m3pi.printf("%f.3 ",b);
     
     
-    // dette er en mega god kommentar 13:44
-    // denen er endnu bedre
-
-    wait(2.0);
-
     m3pi.sensor_auto_calibrate();
-
+    
+    /*Variable initiation*/
     float right;
     float left;
     float current_pos_of_line = 0.0;
@@ -40,6 +30,18 @@
     float power;
     float speed = MAX;
     
+    float batVol = m3pi.battery();  //Storing battery voltage in variable
+    float potVol = m3pi.pot_voltage();  //Storing pot voltage
+    
+    /*Printing test*/
+    m3pi.cls();
+    m3pi.locate(0,0);
+   
+    m3pi.printf("%f.3 ",batVol);
+    m3pi.locate(0,1);
+    m3pi.printf("%f.3 ",b);
+    wait(2.0);
+
     while (1) {
 
         // Get the position of the line.