View Single Post
  #16   Spotlight this post!  
Unread 23-01-2013, 20:08
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: ADXL345_I2C Help

bump. We're having the same issue. Here's ou code:
Code:
#include <WPILib.h>
class DefaultRobot : public SimpleRobot
{	
	ADXL345_I2C *acc;                       
public:
	DefaultRobot(void)
	{	
		acc = new ADXL345_I2C (4, ADXL345_I2C::kRange_2G);
	}
	void Autonomous(void)
	{
			while(IsAutonomous())
			{
			}				
	}
	void OperatorControl(void)
	{
		DriverStationLCD *dsLCD = DriverStationLCD::GetInstance();
		while (IsOperatorControl())
		{	
			while (true)
			{
				float x = acc->GetAcceleration(ADXL345_I2C::kAxis_X);
				float y = acc->GetAcceleration(ADXL345_I2C::kAxis_Y);
				float z = acc->GetAcceleration(ADXL345_I2C::kAxis_Z);
				dsLCD->PrintfLine((DriverStationLCD::Line) 1, "x=%f  y=%f  z=%f", x, y, z);
				dsLCD->UpdateLCD();
				Wait(1.0);
			}
		}
	}
};

START_ROBOT_CLASS(DefaultRobot);
We're not experts. This is our first year programming in C++, and were a little short on time, so there wasn't much time for testing.... If anyone happens to know how to fix it (without any extra effort), we'd love to hear about it. Thanks!
Reply With Quote