Projekt

Dependencies:   PM2_Libary

Revision:
35:57b39290aaea
Parent:
34:f035a1869c34
Child:
36:f678d693969f
--- a/main.cpp	Wed Apr 06 09:32:30 2022 +0200
+++ b/main.cpp	Wed Apr 06 09:58:39 2022 +0200
@@ -33,30 +33,35 @@
 
 
 int main(){
-    enable_motors = 1;
-    user_button.read();
+
+
+    int counter_user_button = 0;
+    bool counter_stopp = 0;
+    enable_motors = 0;
+    
+    while(1){
+        if (user_button.read() & !counter_stopp) {
+            counter_user_button++;
+            counter_stopp = 1;
 
-    int counter_user_button, counter_stopp = 0;
-    if (user_button == 1 && counter_stopp == 0) {
-        counter_user_button++;
-        counter_stopp = 1;
-
-    }
-    if (user_button == 0){
-        counter_stopp = 0;
+        }
+        if (!user_button.read()){
+            counter_stopp = 0;
+        }
+        if (counter_user_button >= 3){
+            counter_user_button = 1;
+        }
+        switch (counter_user_button){
+            case 1:
+            cout <<"case1";
+            enable_motors = 1;
+            break;
+            case 2:
+            cout <<"case2";
+            enable_motors = 0;
+            break;
+        }
     }
-    if (counter_user_button >= 3){
-        counter_user_button = 1;
-    }
-    switch (counter_user_button){
-        case 1:
-        cout <<"case1";
-        break;
-        case 2:
-        cout <<"case2";
-        break;
-    }
-