Questions about ultrasonic

im using wpilib, are the pings automatically sent or i have to call this? please if you can, show me an example of code how to check if the robot is place by 2 inches from a wall.

Are you using LV or WR?
In C++, you have two options. You can repeatedly call the Ping() method, or you can set your sensor to automatic mode using SetAutomaticMode(true). Either way, after you’ve gotten at least one measurement back, use GetRangeInches or GetRangeMM to get the respective measurement.

And if you are using LabView, you can get the manual analog input and divide it by howmany volts the spec sheet says is per centimeter or meter.

It also depends on which ultrasonic sensor you are using. The Maxbotix sensor can deliver the distance as a voltage of 0 to 2.55 volts, corresponding to 0 to 255 inches. In that case you would just read the analog value.

How linear are they and is there a myopic zone?