View Single Post
  #3   Spotlight this post!  
Unread 27-01-2015, 15:21
acastagna acastagna is offline
Registered User
FRC #1493
 
Join Date: Jan 2012
Location: Albany High School
Posts: 36
acastagna is an unknown quantity at this point
Re: Gyro class issue?

Here it is. We can plug the gyro into AI port 1 and get voltage readings. When we plug it into port 0, we get nothing. We switching ports, eliminating the analog channel, and using other gyros.

import edu.wpi.first.wpilibj.smartdashboard.*;
import edu.wpi.first.wpilibj.Gyro
import edu.wpi.first.wpilibj.AnalogInput

public class Robot extends IterativeRobot
{

Gyro gyro = new gyro(1);
AnalogInput ai1 = new AnalogInput(0);
double angle1, voltage1;

public void robotInit()
{
gyro.reset();
}

public void autnoomousPeriodic()
{
}

public void teleopPeriodic()
{
angle1 = gyro.getAngle();
voltage1 = ai1.getAverageVoltage();
SmartDashboard.putString("DB/String 6","gyro = "+angle1);
SmartDashboard.putString("DB/String y","ai1 = "+voltage1);
}

}
Reply With Quote