mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[examples] Add AnalogAccelerometer snippets
Delete AnalogAccelerometer comments about sensitivity and zero constants that don't exist
This commit is contained in:
committed by
Peter Johnson
parent
cc8eaf3ed7
commit
b7cd03adc4
@@ -0,0 +1,25 @@
|
||||
// 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 edu.wpi.first.wpilibj.snippets.analogaccelerometer;
|
||||
|
||||
import edu.wpi.first.wpilibj.RobotBase;
|
||||
|
||||
/**
|
||||
* Do NOT add any static variables to this class, or any initialization at all. Unless you know what
|
||||
* you are doing, do not modify this file except to change the parameter class to the startRobot
|
||||
* call.
|
||||
*/
|
||||
public final class Main {
|
||||
private Main() {}
|
||||
|
||||
/**
|
||||
* Main initialization function. Do not perform any initialization here.
|
||||
*
|
||||
* <p>If you change your main robot class, change the parameter type.
|
||||
*/
|
||||
public static void main(String... args) {
|
||||
RobotBase.startRobot(Robot::new);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// 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 edu.wpi.first.wpilibj.snippets.analogaccelerometer;
|
||||
|
||||
import edu.wpi.first.wpilibj.AnalogAccelerometer;
|
||||
import edu.wpi.first.wpilibj.TimedRobot;
|
||||
|
||||
/**
|
||||
* AnalogAccelerometer snippets for frc-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 m_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
|
||||
m_accelerometer.setSensitivity(1);
|
||||
// Sets the zero voltage of the accelerometer to 3 volts
|
||||
m_accelerometer.setZero(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleopPeriodic() {
|
||||
// Gets the current acceleration
|
||||
m_accelerometer.getAcceleration();
|
||||
}
|
||||
}
|
||||
@@ -113,5 +113,17 @@
|
||||
"foldername": "analogpotentiometer",
|
||||
"gradlebase": "java",
|
||||
"mainclass": "Main"
|
||||
},
|
||||
{
|
||||
"name": "AnalogAccelerometer",
|
||||
"description": "Snippets of Analog Accelerometer for frc-docs.",
|
||||
"tags": [
|
||||
"Hardware",
|
||||
"Analog",
|
||||
"Accelerometer"
|
||||
],
|
||||
"foldername": "analogaccelerometer",
|
||||
"gradlebase": "java",
|
||||
"mainclass": "Main"
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user