task main()
{
//written by Jason Atwood
// 10/12/2009
// this is a little test to see if your HiTechnic Compass Sensor is working
// it records the reading every 500 milliseconds and writes it to a file
// the two key lines are the SetSensorLowspeed and SensorHTCompass
byte fileHandle;
short bytesWritten;
int heading1; //heading (0-359 value)
SetSensorLowspeed(IN_1); //compass sensor in port 1
DeleteFile("compass.txt");
CreateFile("compass.txt", 512, fileHandle);
while(true){
heading1 = SensorHTCompass(IN_1); // get current heading
string heading_str1 = NumToStr(heading1);
WriteLnString(fileHandle, heading_str1, bytesWritten);
Wait(500);
}
}