A simple sketch I used to learn Adafruit's HMC5883L triple-axis magnometer.