Skip to content

Analog gyro

CoolProGamer edited this page Feb 6, 2025 · 5 revisions

AnalogGyro is a public class that allows us to track the direction the robot is facing in reference to the starting position of the robot. The analog gyro measures in degrees and has a lot of useful methods.

AnalogGyro can be initialized in your code using the code below, inside of it you can configure which analog port, which can either be 0 or 1.

// Creates an AnalogGyro object on port 0
AnalogGyro gyro = new AnalogGyro(0);

A few pieces of code to use this include

  • void calibrate() which calibrates the gyro by running samples and choosing the median
  • AnalogInput GetAnalogInput gets the analog input

More info for code applications can be found on this WPILIB page

Clone this wiki locally