Julesnaps / Mbed 2 deprecated Linefollowproject

Dependencies:   m3pi mbed

Revision:
8:5640c8c5088e
Parent:
7:ac88c8e35048
Child:
9:7b9094864268
diff -r ac88c8e35048 -r 5640c8c5088e main.cpp
--- a/main.cpp	Wed Oct 05 11:54:30 2022 +0000
+++ b/main.cpp	Thu Oct 06 11:26:16 2022 +0000
@@ -12,10 +12,8 @@
 #define I_TERM 0
 #define D_TERM 20
 
-
-
 // Prototypes
-int PitTest(int gotoPit); 
+int PitTest(void);   // Test if to robot needs to goto pit 
 
 int main() {
     
@@ -57,9 +55,9 @@
 
     
     while (1) {
-        
+        /* If cycle count divided by 100 does not have a rest. test if pit */
         if (ccount %100 == 0 && gotoPit=0){
-            gotoPit=PitTest(gotoPit);
+            gotoPit = PitTest(void);
             }
     
         // Get the position of the line.
@@ -97,33 +95,30 @@
         m3pi.left_motor(left);
         m3pi.right_motor(right);
         
-    cyclecount++;
+    ccount++;
     }
 }
 
 
-int PitTest(int gotoPit){
+int PitTest(void){
 /* Test the batteri voltage if the robot is not headed for pit */ 
     
-    float batVol = m3pi.battery();  //Storing battery voltage in variable
-    const float BATVOLTRESHOLD = 3.0; // Treshold i volt
+    const float BATVOLTTRESHOLD = 3.0; // Treshold i volt
+    int result;
     
     /*Digital outs*/
     DigitalOut led1(LED1);
     led1 = 0; // Turn off led 1 on the embed
-
-    /*Updates battery voltage*/
-    batVol = m3pi.battery(); 
     
     /*Test if the voltage is below the treshold if so turn on go to pit mode*/
-    if batteryVoltage <= BATVOLTRESHOLD (){  
-        gotoPit = 1; // set goto pit condition
-        led1 = 1; // trun on Led 1
+    if (m3pi.battery() <= BATVOLTTRESHOLD ()){  
+        result = 1; // set goto pit condition
+        led1 = 1; // turn on Led 1
         m3pi.cls();
         m3pi.locate(0,0);
         m3pi.printf("Going to");
         m3pi.locate(0,1);
         m3pi.printf("PIT Party");
     }
-
+    return result;
 }
\ No newline at end of file