Good

Dependencies:   HCSR04 mbed

Fork of Nucleo_Robotik by Contest IOT GSE5

Files at this revision

API Documentation at this revision

Comitter:
Alex_Hochart
Date:
Wed Jan 06 19:47:15 2016 +0000
Parent:
1:47b9204516a0
Commit message:
Good;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 47b9204516a0 -r 9b4d9afa44a3 main.cpp
--- a/main.cpp	Wed Jan 06 15:20:09 2016 +0000
+++ b/main.cpp	Wed Jan 06 19:47:15 2016 +0000
@@ -69,7 +69,8 @@
     
     int distFront = 22;
     int distBack = 22;
-    int difDist;
+    int difDist, distMoy;
+    
     
     B_R = 0;
     F_R = 0;
@@ -85,17 +86,28 @@
         distBack = sensorBack.distance(1);
         
         difDist = distBack - distFront;
+        distMoy= (distBack + distFront)/2;
         
+        if(distMoy<10){
+            //tourne à droite et avance
+            rotationD(0.6);
+        }else if(distMoy>30){
+            rotationG(0.6);
+        }
+            //notre programme
+            
         if(difDist<-10){
-            rotationG(0.8); //rotation à gauche
-        }else if(difDist<0){
+            rotationG(0.6); //rotation à gauche
+        }else if(difDist<-2){
             rotationG(0.8); //rotation à gauche
             avancer(0.7);
-        }else if(difDist>0){
+        }else if(difDist>2){
             rotationD(0.8);    //rotation à droite
             avancer(0.7);
         }else if(difDist>10){
-            rotationG(0.8);
+            rotationG(0.6);
+        }else {
+            avancer(0.7);
         }
 
     }