I'm assuming that your sensor is a MaxBotix MB1013 and that the following is the data sheet for your sensor.
http://www.maxbotix.com/documents/HR..._Datasheet.pdf
Assuming that is your sensor, I would recommend that you start with pins 3, 6 and 7 on the sensor and connect them to an analog input on the roboRIO (refer to the data sheet to determine how they should be connected). The following class could then be used to display readings from the sensor on the SmartDashboard to help you determine how the voltage output from the sensor corresponds to distance.
You will need to determine the constant (VOLTS_TO_DIST) to convert the voltage to a real world distance (if you want to work in real world units instead of voltage).
Code:
package org.usfirst.frc.team868.robot.sensors;
import edu.wpi.first.wpilibj.AnalogInput;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
public class DistanceSensor {
// A MB1013 distance sensor - http://www.maxbotix.com/documents/HRLV-MaxSonar-EZ_Datasheet.pdf
// (pins 3, 6 and 7 from sensor to analog input 0)
private static final AnalogInput mb1013 = new AnalogInput(0);
// TODO - You will need to determine how to convert voltage to distance
// (use information from the data sheet, or your own measurements)
private static final double VOLTS_TO_DIST = 1.0;
public static double getVoltage() {
return mb1013.getVoltage();
}
public static double getDistance() {
return getVoltage() * VOLTS_TO_DIST;
}
public static void updateDashboard() {
SmartDashboard.putNumber("Distance (volts)", getVoltage());
SmartDashboard.putNumber("Distance (real)", getDistance());
}
}
NOTE: You will need to periodically call the Distance.updateDashboard() command to see the values on the dashboard.