MoJo / ER2_Robot_gnuarmeclipse_lpc1768-V2

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
joehatier
Date:
Fri May 24 10:57:58 2019 +0000
Parent:
0:1a801a2a7b4b
Commit message:
Ligne;

Changed in this revision

ER2_Robot/fonction.h Show annotated file Show diff for this revision Revisions of this file
ER2_Robot/globals.cpp Show annotated file Show diff for this revision Revisions of this file
ER2_Robot/suivi.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/ER2_Robot/fonction.h	Fri Feb 15 15:25:57 2019 +0000
+++ b/ER2_Robot/fonction.h	Fri May 24 10:57:58 2019 +0000
@@ -1,4 +1,8 @@
 #ifndef FONCTION_H
+
+
+#include "SRF05.h"
+
 extern Ticker TI;
 extern InterruptIn ENCODEUR_G ;
 extern DigitalIn ENCODEUR_D ;
@@ -11,7 +15,7 @@
 extern AnalogIn CPTG;
 extern AnalogIn CPTD;
 extern AnalogIn BAT;
-//extern SRF05 SRF;
+extern SRF05 SRF;
 
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ER2_Robot/globals.cpp	Fri May 24 10:57:58 2019 +0000
@@ -0,0 +1,15 @@
+#include "mbed.h"
+#include"SRF05.h"
+#include "fonction.h"
+
+
+SRF05 SRF(p13,p14);
+DigitalOut SensG(p12);//Sens Gauche
+DigitalOut SensD(p11);//Sens Droite
+PwmOut PWMG(p23); //Sortie moteur gauche
+PwmOut PWMD(p22); //Sortie moteur droit
+DigitalIn BpD(p29);
+DigitalIn BpG(p30);  
+AnalogIn CPTG (p20);
+AnalogIn CPTD (p19);
+AnalogIn BAT (p15);
\ No newline at end of file
--- a/ER2_Robot/suivi.cpp	Fri Feb 15 15:25:57 2019 +0000
+++ b/ER2_Robot/suivi.cpp	Fri May 24 10:57:58 2019 +0000
@@ -3,29 +3,19 @@
 #include "fonction.h"
 #define ARRET 0
 #define ROULE 1
+#define DIST 2
 #include "SRF05.h"
 
-SRF05 SRF(p13,p14);
-DigitalOut SensG(p12);//Sens Gauche
-DigitalOut SensD(p11);//Sens Droite
-PwmOut PWMG(p23); //Sortie moteur gauche
-PwmOut PWMD(p22); //Sortie moteur droit
-DigitalIn BpD(p29);
-DigitalIn BpG(p30);  
-AnalogIn CPTG (p20);
-AnalogIn CPTD (p19);
-AnalogIn BAT (p15);
-
 float srf;
 
 int main()
 {
-    float cptG,cptD,E,k=18,EG,ED/*,bat*/;
+    float cptG,cptD,E,k=19,EG,ED/*,bat*/;
     PWMG.period_us(100);
     PWMD.period_us(100);
-    int /*J,S,*/etat=ROULE/*,bpg,bpd*/;
-    BpD.mode(PullUp);
-    BpG.mode(PullUp);
+    int /*J,S,*/etat=ARRET/*,bpg,bpd*/;
+    //BpD.mode(PullUp);
+    //BpG.mode(PullUp);
   
     while(1) {
         
@@ -50,9 +40,13 @@
             case ARRET :                            // A l'arret
                 if(srf>=25) etat=ROULE;
                 break;                       
-            case ROULE :                            // Jack débranché => robot avance
+            case ROULE :  
+                if(25<srf<=29) etat=DIST;                          // Jack débranché => robot avance
                if(srf<=25) etat=ARRET; 
                 break;
+            case DIST :                            // A l'arret
+                if(srf>=25) etat=ROULE;
+                break;   
             
 
 
@@ -70,6 +64,10 @@
                 roule_motdroit(0,(int)(ED));                                  // Roule 
                 printf("Measured : %.1f\n\r", srf);
                 break;
+            case DIST :                           
+                roule_motgauche(0,(int)(EG-10));
+                roule_motdroit(0,(int)(ED-10));
+                break;          
         }
 
 }