MRJJ / clickers

Dependents:   ROCO104_Buggy BuggyDesign

Revision:
3:91541ffdf9a5
Parent:
2:2571dd52276f
Child:
4:595e353826e5
--- a/clickers.cpp	Fri Mar 06 16:54:11 2020 +0000
+++ b/clickers.cpp	Tue Mar 17 13:13:46 2020 +0000
@@ -10,23 +10,35 @@
 extern int mm;
 extern void dist();
 extern bool rStopped, fStopped;
-
+int countDis = 0;
 void RevStop()
 {
-    while (microswitch1 == true)
+    if (microswitch1 == true)
     {
         microswitch1.read();        
         Wheel.Stop();
         rStopped = true;
+        dist();
     }
-
+}
 void FwdStop()
 {
-    while (mm<= 500)
+    dist();
+    if (mm<= 500)
+    {
+        countDis++;
+        dist();
+    }
+    else if (mm<= 500 && countDis > 20)
     {
-        ultra_sonic_distance();
         Wheel.Stop();
-        fStopped = true
+        fStopped = true;
+        dist();
+    }
+    else
+    {
+        countDis = 0;
+        fStopped = false;  
         dist();
     }
 }
\ No newline at end of file