Arduino Library – HMC5883L (Creative Electronics)
Installatie van Arduino IDE libraries: Arduino info
The code I provide with this post is based on the code found
here, but at the time this post is written, the original code won’t work. There are some huge bugs as floating point number comparison that will not allow you to change the scale factor of the sensor, and some queer bugs on error handling (basically that code doesn’t check for error at all, as you can easily prove executing it: it will always display an error setting the scale, and setting the measurement mode. More oddly this latter error display the same message because the error variable is not reset after its use). Of course even my library will have some bugs too, and it’s not complete at all, but it’s a good start to familiarize with the sensor itself.
Directe download site: Download HMC5883L bibliotheek @ bluelemonlabs.blogspot.nl