// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

package org.wpilib.snippets.adxlaccelerometers;

import org.wpilib.framework.TimedRobot;
import org.wpilib.hardware.accelerometer.ADXL345_I2C;
import org.wpilib.hardware.bus.I2C;

/**
 * ADXL345, 362 Accelerometer snippets for wpilib-docs.
 * https://docs.wpilib.org/en/stable/docs/software/hardware-apis/sensors/accelerometers-software.html
 */
public class Robot extends TimedRobot {
  // Creates an ADXL345 accelerometer object with a measurement range from -8 to 8 G's
  ADXL345_I2C accelerometer345I2C = new ADXL345_I2C(I2C.Port.PORT_0, 8);

  /** Called once at the beginning of the robot program. */
  public Robot() {}

  @Override
  public void teleopPeriodic() {
    // Gets the current acceleration in the X axis
    accelerometer345I2C.getX();
    // Gets the current acceleration in the Y axis
    accelerometer345I2C.getY();
    // Gets the current acceleration in the Z axis
    accelerometer345I2C.getZ();
  }
}
