You are viewing an older revision! See the latest version
HMC6352 Digital Compass
The HMC6352 is a digital compass with an I2C interface.
Hello World!¶
main.cpp
#include "HMC6352.h"
HMC6352 compass(p28, p27);
Serial pc(USBTX, USBRX);
int main() {
pc.printf("Starting HMC6352 test...\n");
//Continuous mode, periodic set/reset, 20Hz measurement rate.
compass.setOpMode(HMC6352_CONTINUOUS, 1, 20);
while (1) {
wait(0.1);
pc.printf("Heading is: %f\n", compass.sample() / 10.0);
}
}
| HMC6352 Signal Name | mbed pin |
| Vcc | Vout |
| Gnd | Gnd |
| SCL | p27 |
| SDA | p28 |
API¶
[Not found]
Library¶
[Not found]