Sample for the HMC5883L.

Dependencies:   HMC5883L mbed

Fork of Seeed_Grove_Digital_Compass_Example by Seeed

Committer:
tichise
Date:
Wed Oct 03 13:34:47 2018 +0000
Revision:
1:e368e2a71ea8
Parent:
0:74dc5ccb0b73
add

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 0:74dc5ccb0b73 1 #include "mbed.h"
sam_grove 0:74dc5ccb0b73 2 #include "HMC5883L.h"
tichise 1:e368e2a71ea8 3
tichise 1:e368e2a71ea8 4 HMC5883L compass(p9, p10);
sam_grove 0:74dc5ccb0b73 5
sam_grove 0:74dc5ccb0b73 6 int main(void)
sam_grove 0:74dc5ccb0b73 7 {
sam_grove 0:74dc5ccb0b73 8 int16_t data[3] = {0};
sam_grove 0:74dc5ccb0b73 9 double heading = 0.0f;
sam_grove 0:74dc5ccb0b73 10
sam_grove 0:74dc5ccb0b73 11 compass.init();
sam_grove 0:74dc5ccb0b73 12
sam_grove 0:74dc5ccb0b73 13 while(1) {
sam_grove 0:74dc5ccb0b73 14 compass.getXYZ(data);
sam_grove 0:74dc5ccb0b73 15 wait(0.1f);
sam_grove 0:74dc5ccb0b73 16 heading = compass.getHeadingXYDeg();
tichise 1:e368e2a71ea8 17 // printf("x: %4d, y: %4d, z: %4d\n", data[0], data[1], data[2]);
tichise 1:e368e2a71ea8 18 printf("heading: %3.0f\n", heading);
sam_grove 0:74dc5ccb0b73 19 wait(1.0f);
sam_grove 0:74dc5ccb0b73 20 }
sam_grove 0:74dc5ccb0b73 21 }
tichise 1:e368e2a71ea8 22