View Single Post
  #3   Spotlight this post!  
Unread 15-01-2012, 23:36
ggorsuch ggorsuch is offline
Registered User
FRC #2471 (Team Mean Machine)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Camas, WA
Posts: 21
ggorsuch is an unknown quantity at this point
Re: ADXL345 accelerometer problems

It is wired using the 4 i2c pins of the accelerometer to the 4 i2c pins on the digital sidecar.
Here is our code:
Code:
package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.*;
import edu.wpi.first.wpilibj.ADXL345_I2C.AllAxes;

public class RobotTemplate extends IterativeRobot {
    ADXL345_I2C accelerometer;
    
    public void robotInit() {
        accelerometer = new ADXL345_I2C(1, ADXL345_I2C.DataFormat_Range.k4G);
    }
    public void autonomousPeriodic() {
        ;;
    }
    public void teleopPeriodic() {
        AllAxes ac = accelerometer.getAccelerations();
        System.out.println("X: "+ac.XAxis+" Y: "+ac.YAxis+" Z: "+ac.ZAxis);
    }
    
}
Reply With Quote