NXC  Version 1.2.1 r5
 All Data Structures Files Functions Variables Groups Pages
byte SensorUS ( const byte  port)
inline

Read ultrasonic sensor value.

Return the ultrasonic sensor distance value. Since an ultrasonic sensor is an I2C digital sensor its value cannot be read using the standard Sensor(n) value. The port must be configured as a Lowspeed port before using this function. This function includes a 15 millisecond wait before reading the sensor value due to the ultrasonic sensor getting into a bad state if you try to read its value more frequently than once every 15 milliseconds.

Parameters
portThe port to which the ultrasonic sensor is attached. See the Input port constants group. You may use a constant or a variable.
Returns
The ultrasonic sensor distance value (0..255)
Examples:
ex_SensorUS.nxc.