Sample for the HMC5883L.

Dependencies:   HMC5883L mbed

Fork of Seeed_Grove_Digital_Compass_Example by Seeed

main.cpp

Committer:
tichise
Date:
2018-10-03
Revision:
1:e368e2a71ea8
Parent:
0:74dc5ccb0b73

File content as of revision 1:e368e2a71ea8:

#include "mbed.h"
#include "HMC5883L.h"
 
HMC5883L compass(p9, p10);
 
int main(void)
{
    int16_t data[3] = {0};
    double heading = 0.0f;
    
    compass.init();
    
    while(1) {
        compass.getXYZ(data);
        wait(0.1f);
        heading = compass.getHeadingXYDeg();
        // printf("x: %4d, y: %4d, z: %4d\n", data[0], data[1], data[2]);
        printf("heading: %3.0f\n", heading);
        wait(1.0f);
    }
}