Sample for the HMC5883L.

Dependencies:   HMC5883L mbed

Fork of Seeed_Grove_Digital_Compass_Example by Seeed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "HMC5883L.h"
00003  
00004 HMC5883L compass(p9, p10);
00005  
00006 int main(void)
00007 {
00008     int16_t data[3] = {0};
00009     double heading = 0.0f;
00010     
00011     compass.init();
00012     
00013     while(1) {
00014         compass.getXYZ(data);
00015         wait(0.1f);
00016         heading = compass.getHeadingXYDeg();
00017         // printf("x: %4d, y: %4d, z: %4d\n", data[0], data[1], data[2]);
00018         printf("heading: %3.0f\n", heading);
00019         wait(1.0f);
00020     }
00021 }
00022