The HiTechnic Compass plugs directly into the i^2c port on the digital sidecar. Programming it in C++ with the WPI library is incredibly simple, see program below.
Here's the WPI doc on it:
http://www.virtualroadside.com/WPILi...c_compass.html
Code:
#include "WPILib.h"
class CompassBot : public SimpleRobot {
HiTechnicCompass compass; // Define compass object
public:
float angle;
CompassBot(void):
compass(1) // Initialize to i2c port 1
{
GetWatchdog().SetExpiration(0.1);
}
void Autonomous(void) { }
void OperatorControl(void) {
while (IsOperatorControl()) {
angle = compass.GetAngle(); // Get the angle (returns float)
printf("Current Angle: %f", angle); // Print angle
}
}
};
START_ROBOT_CLASS(CompassBot);