test

Dependencies:   HCSR04 HMC5883L mbed

Files at this revision

API Documentation at this revision

Comitter:
sedid
Date:
Fri Jun 09 05:23:04 2017 +0000
Commit message:
test boussole;

Changed in this revision

HCSR04.lib Show annotated file Show diff for this revision Revisions of this file
HMC5883L.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 85467ac58aa4 HCSR04.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HCSR04.lib	Fri Jun 09 05:23:04 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/prabhuvd/code/HCSR04/#71da0dbf4400
diff -r 000000000000 -r 85467ac58aa4 HMC5883L.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HMC5883L.lib	Fri Jun 09 05:23:04 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/gmatjuara/code/HMC5883L/#cad18db1e431
diff -r 000000000000 -r 85467ac58aa4 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jun 09 05:23:04 2017 +0000
@@ -0,0 +1,47 @@
+#include "mbed.h"
+#include "math.h"
+#include <HMC5883L.h>
+#include "hcsr04.h"
+#define PI 3.14159265359
+#define PERIOD 0.0001
+
+//Boussole
+HMC5883L toto(p28,p27);
+
+int main()
+{
+   
+
+    toto.setDefault();
+    int Mx,My,Mz;
+    float x,y,z;
+  
+  
+ 
+    while(1) {
+        //Boussole
+        Mx=toto.getMx();
+        My=toto.getMy();
+        Mz=toto.getMz();
+        if(Mx>32500) Mx=Mx-65535;
+        if(My>32500) My=My-65535;
+        if(Mz>32500) Mz=Mz-65535;
+        x=atan2((float)My,(float)Mx);
+        y=atan2((float)Mz,(float)Mx);
+        z=atan2((float)Mz,(float)My);
+        if(x<0)x+=2*PI;
+        if(x>2*PI)x-=2*PI;
+        if(y<0)y+=2*PI;
+        if(y>2*PI)y-=2*PI;
+        if(z<0)z+=2*PI;
+        if(z>2*PI)z-=2*PI;
+        x=x*180/PI;
+        y=y*180/PI;
+        z=z*180/PI;
+        float error=90-y;
+        printf("angle:%d\t %d\t%d\n\r",My,Mx,Mz);
+       }
+       
+       }
+
+
diff -r 000000000000 -r 85467ac58aa4 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jun 09 05:23:04 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ef9c61f8c49f
\ No newline at end of file