HiTechnic compass - reading 65535?

Is this how to use the HiTechnic compass?


  HiTechnicCompass *m_compass;
  float CompassAngle;

....

  m_compass = new HiTechnicCompass(4); // slot 4

....

  CompassAngle = m_compass->GetAngle();

The CompassAngle readings are always 65535.0. We checked the cable continuity from the I2C connector on the sidecar to the compass module and it seems ok. See anything wrong?

That looks correct. I looked at some of my compass test code, and I didn’t have to do anything else. I wrote my compass code pre-season and I was using an older version of WPILib, so it may have changed since then.

Do you have another compass and cable to test with? Did you try your other DSC?

do you know because of a printf?
we had a wierd output and it was because it was
printf("%i
“, floatvalue);
when it should have been
printf(”%f
", floatvalue);

Thanks for the replies. We replaced the cable with another and the problem went away, so it was a bad cable. The code does work and the compass is working well.