Ultrasonic Coding Help

Hello. We decided this year that we would use an ultrasonic for figuring out distance.

We are having a bit of an issue with programming it. We are trying to get it to continuously print out the distance but have failed in our attempts. If someone can direct us in the right direction that would be greatly appreciated.

Code used:

public class Robot extends IterativeRobot{
Ultrasonic ultra = new Ultrasonic(7,8);

public void robotInit (){

ultra.setAutomaticMode(true);
}
public void ultrasonicPeriodic(){

	double range = ultra.getRangeInches();

}
}

*Note: this is just a part of our code not the entire thing, and yes we have the library.

Which sensor are you using? If you are using the maxbotix sensor, it should be declared as an Analog Input object using one analog input port on the roborio. See my response here

https://www.chiefdelphi.com/forums/showthread.php?t=161943

How are you printing the values? There’s nothing in your snippet that would print the results. You should post your full code ( or more of it).