View Single Post
  #2   Spotlight this post!  
Unread 30-01-2010, 16:56
basicxman basicxman is offline
Emily Horsman
FRC #2200 (MMRambotics)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Burlington, Ontario
Posts: 971
basicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant future
Send a message via AIM to basicxman Send a message via MSN to basicxman Send a message via Yahoo to basicxman
Re: Which Compass to Use?

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);