View Single Post
  #3   Spotlight this post!  
Unread 30-01-2017, 02:48
TakeItEasy TakeItEasy is offline
Registered User
FRC #3034
 
Join Date: Jan 2017
Location: Israel
Posts: 2
TakeItEasy is an unknown quantity at this point
Re: accelerometer return acceleration 0

Quote:
Originally Posted by acastagna View Post
Post your code
Code:
public class Robot extends IterativeRobot {
	RobotDrive myRobot;
	Joystick joystick;
	ADXL362  acc;
	CANTalon[] drive = new CANTalon[4];
	
	@Override
	public void robotInit() 
	{
		for(int i = 1; i < 5; i++)drive[i-1] = new CANTalon(i);
		myRobot = new RobotDrive(drive[2],drive[0]);
		joystick = new Joystick(0);
		acc = new ADXL362(Accelerometer.Range.k4G);
	}

	@Override
	public void autonomousInit() {
		
	}

	@Override
	public void autonomousPeriodic() {

	}

	@Override
	public void teleopInit() {
	}

	@Override
	public void teleopPeriodic() {
		myRobot.arcadeDrive(joystick);
		if(acc.getX() != 0)System.out.println("X " + acc.getX());
		if(acc.getY() != 0)System.out.println("Y " + acc.getY());
		if(acc.getZ() != 0)System.out.println("Z " + acc.getZ());
	}

	@Override
	public void testPeriodic() {
		LiveWindow.run();
	}
}
i tried this code for testing but it doesnt print anything.
Reply With Quote