Paclay-Saris pod racers / Mbed 2 deprecated Algo_charges_fictives_3

Dependencies:   mbed

Revision:
17:4a65cce4ac4f
Parent:
15:f8c5007343f9
--- a/main.cpp	Thu Jun 06 14:38:58 2019 +0000
+++ b/main.cpp	Thu Jun 06 15:40:53 2019 +0000
@@ -14,6 +14,7 @@
 int compteur_tours_lidar = 0;
 int affiche_lidar = 0;
 bool run = false;
+bool stop = true;
 
 // Défintion des pwm
 PwmOut pwm_lidar(PB_15); // pwm du Lidar
@@ -62,10 +63,10 @@
     for (i=0; i<360; i++) {
         liste_fictifs[i] = 0;
     }
-     for (i=90; i<=270; i++) {
-         //for (int i=0; i<180; i++){ //test
-         liste_fictifs[i] = 1;
-     }
+    for (i=90; i<=270; i++) {
+        //for (int i=0; i<180; i++){ //test
+        liste_fictifs[i] = 1;
+    }
     //liste_fictifs[180] = 1;
 
     avg_x = 0;
@@ -83,7 +84,7 @@
             if(theta != 0) r = list_lidar[360-theta];
             else r = list_lidar[0];
 
-            }
+        }
 
         if (r != 0) {
 
@@ -205,6 +206,7 @@
             pc.printf("%c \n\r",entree);
             if (entree == 'a') {
                 run = true;
+                stop = false;
             }
             if (entree == 'z') {
                 run = false;
@@ -229,11 +231,15 @@
             pwm_direction_value = angle_servo(dir); // calcul du pwm
         }
 
-        if (1) {
+        if (run==true) {
             // vitesse constante
-            pwm_moteur.pulsewidth_us(1440);
+            if (stop==false) {
+                pwm_moteur.pulsewidth_us(1440);
+                stop=true;
+            }
             pwm_direction.pulsewidth_us(pwm_direction_value); // commande du pwm du moteur
         } else {
+            stop=false;
             pwm_moteur.pulsewidth_us(1480);
         }