I'm using HMC5883L
the below test program outputs negative values for the angle and does not seem to match with the expected (0 to 360) range.
Has any one used a program for HMC5883L that simply outputs the angle from north direction ?
#include <Wire.h>
#include <HMC.h>
//#include <ArduinoRobot.h>
int a;
void setup()
{
Serial.begin(9600);
}
void loop()
{
int x,y,z;
delay(100); // There will be new values every 100ms
HMC.getValues(&x,&y,&z);
Serial.print("x:");
Serial.print(x);
Serial.print(" y:");
Serial.print(y);
Serial.print(" z:");
Serial.println(z);
HMC.getAngle(&a);
Serial.println(a);
}