|
Re: 2010 Accelerometer I2C Object/Class
Here is my test program:
Code:
public class RobotTest extends SimpleRobot {
ADXL345DigitalAccelerometer accelerometer = new ADXL345DigitalAccelerometer(4);
public RobotTest()
{
accelerometer.intitialize();
accelerometer.setRange(ADXL345DigitalAccelerometer.DATA_FORMAT_16G);
}
/**
* This function is called once each time the robot enters autonomous mode.
*/
public void autonomous() {
}
/**
* This function is called once each time the robot enters operator control.
*/
public void operatorControl() {
this.getWatchdog().setEnabled(false);
while( this.isOperatorControl() && this.isEnabled() )
{
System.out.println("Accel X, Y, Z: " + accelerometer.getXAxis() + " " + accelerometer.getYAxis() + " " + accelerometer.getZAxis() );
Timer.delay(0.001);
}
}
}
Wiring should be from the I2C header on the digital side car. The I2C header is the row of 4 pins directly behind the special Lego RJ12 connector. Wire 5V to 5V, 0V to (-), SDA to SDA, SCL to SCL. Do not use the second row of pins labeled 1,2,3,&4.
__________________
FRC 623 2003,2004,2005,2006,2007,2008, 2009, 2010, 2011
FRC 1900 2007
FVC 60 and 193 2006
FVC 3271 2007
FTC 226 and 369 2008, 2009, 2010, 2011
FTC 3806 2010
|