k

Dependencies:   mbed Motor

Files at this revision

API Documentation at this revision

Comitter:
mksaga
Date:
Thu May 02 00:12:18 2019 +0000
Parent:
8:e0cd3bd2d051
Commit message:
autonomy;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r e0cd3bd2d051 -r a9d4cb88f0b0 main.cpp
--- a/main.cpp	Wed May 01 07:52:54 2019 +0000
+++ b/main.cpp	Thu May 02 00:12:18 2019 +0000
@@ -65,8 +65,9 @@
     float fS;
     float fW;
     float fC;
-    
-    while(1) { 
+    int i = 0;
+    while(1) {
+        i++; 
         /*
         open_v1();wait(1);
         seal_v1();wait(1);
@@ -92,7 +93,7 @@
         wait(1);
         */
         
-        /*
+        
         fN = flexN.read();
         fE = flexE.read();
         fS = flexS.read();
@@ -102,16 +103,47 @@
         printf("       %1.2f\n", fN);
         printf("%1.2f   %1.2f    %1.2f\n", fW, fC, fE);
         printf("       %1.2f\n\n", fS);
+        
+        float restingN;
+        float restingS;
+        float restingW;
+        float restingC;
+        
+        if (i < 3) {
+            restingN = fN;
+            restingS = fS;
+            restingW = fW;
+            restingC = fC;
+        } else {
+            /*
+            if (fN+fS+fW+fC < 0.8*(restingN+restingS+restingW+restingC) & 
+                fN+fS+fW+fC > 0.4*(restingN+restingS+restingW+restingC) {
+            
+            } else if (fN+fS+fW+fC < 0.2*(restingN+restingS+restingW+restingC)
+            */
+            if (fS < 0.08) {
+                activate_v(4);
+                run_pump(5);
+            } else if (fW < 0.08) {
+                activate_v(1);
+                run_pump(5);
+            }
+        }
+        
+        
+        
         wait_ms(2000);
-        */
+        
         //activate_v(1);
         //while(1) { run_pump(15); }
         
+        /*
         for (int i=1; i<=4; i++) {
             activate_v(i);
             run_pump(5);
             wait(1);
         }
+        */