Seeed
/
Seeed_Grove_Digital_Compass_Example
Example using the HMC5883L compass
Revision 0:74dc5ccb0b73, committed 2014-08-15
- Comitter:
- sam_grove
- Date:
- Fri Aug 15 22:28:54 2014 +0000
- Commit message:
- Initial commit
Changed in this revision
diff -r 000000000000 -r 74dc5ccb0b73 HMC5883L.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HMC5883L.lib Fri Aug 15 22:28:54 2014 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/tylerjw/code/HMC5883L/#bc4e1201e092
diff -r 000000000000 -r 74dc5ccb0b73 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Aug 15 22:28:54 2014 +0000 @@ -0,0 +1,22 @@ + +#include "mbed.h" +#include "HMC5883L.h" + +HMC5883L compass(D14, D15); + +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.2f\n", heading); + wait(1.0f); + } +}
diff -r 000000000000 -r 74dc5ccb0b73 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Aug 15 22:28:54 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013 \ No newline at end of file