// 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.analogaccelerometer;

import org.wpilib.framework.TimedRobot;
import org.wpilib.hardware.accelerometer.AnalogAccelerometer;

/**
 * AnalogAccelerometer 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 analog accelerometer on analog input 0
  AnalogAccelerometer accelerometer = new AnalogAccelerometer(0);

  /** Called once at the beginning of the robot program. */
  public Robot() {
    // Sets the sensitivity of the accelerometer to 1 volt per G
    accelerometer.setSensitivity(1);
    // Sets the zero voltage of the accelerometer to 3 volts
    accelerometer.setZero(3);
  }

  @Override
  public void teleopPeriodic() {
    // Gets the current acceleration
    accelerometer.getAcceleration();
  }
}
