HMC5843 Hello World example

Dependencies:   mbed

Revision:
0:5fa326f3d8b1
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);   
+         
+     
+ 
+     }
+ 
+}