HMC5843 Hello World example

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
elrafapadron
Date:
Sun Oct 17 22:23:54 2010 +0000
Commit message:

Changed in this revision

HMC5843.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 5fa326f3d8b1 HMC5843.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HMC5843.lib	Sun Oct 17 22:23:54 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/elrafapadron/code/HMC5843/#fdab96fc6fff
diff -r 000000000000 -r 5fa326f3d8b1 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Oct 17 22:23:54 2010 +0000
@@ -0,0 +1,42 @@
+#include "HMC5843.h"
+ 
+HMC5843 compass(p28, p27);
+Serial pc(USBTX, USBRX);
+
+//Magnetics values x,y,z
+int readings[3];
+
+//ID Buffer
+char buffer[3];
+
+ 
+int main() {
+
+     pc.printf("Starting HMC5843 test...%c%c",13,10);
+     
+     //ID should be H43
+     compass.getAddress(buffer);
+     pc.printf("Magnetic Compass  Id=%c%c%c \n\r",buffer[0],buffer[1],buffer[2]);
+     
+    //Continuous mode, , 10Hz measurement rate.
+    // HMC5843_CONTINUOUS, HMC5843_10HZ_NORMAL HMC5843_1_0GA
+     compass.setDefault();
+     
+     //Wait some time(Need at least 5ms)
+     wait(.1);
+     
+        
+     while(1){
+    
+    
+        compass.readData(readings);
+    
+        pc.printf("Magnetic Values  Mx=%i, My=%i and Mz=%i %c%c",(int16_t)readings[0],(int16_t)readings[1],(int16_t)readings[2] ,13,10);
+       
+         wait(0.1);   
+         
+     
+ 
+     }
+ 
+}
diff -r 000000000000 -r 5fa326f3d8b1 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Oct 17 22:23:54 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e