VEX EDR Python API
Public Member Functions | List of all members
vex.UltrasonicSensor Class Reference

Config Ultrasonic distance sensor. More...

Public Member Functions

def __init__ (self, digitalnum, unit=UNIT_CM)
 
def distance (self)
 Get the distance indicated by the sensor. More...
 
def set_unit_inch (self)
 Set the distance unit to inches. More...
 
def set_unit_cm (self)
 Set the distance unit to centimeters. More...
 
def set_unit_mm (self)
 Set the distance unit to millimeters. More...
 

Detailed Description

Config Ultrasonic distance sensor.

Occupies two ports. Connect the INPUT cable the specified port, and the OUTPUT cable to the next port.

Parameters
digitalnumfirst of the two consecutive digital ports the sensor is connected to (1-11).
unitUnit type: UNIT_CM, UNIT_MM or UNIT_INCH. Default UNIT_CM.

Constructor & Destructor Documentation

◆ __init__()

def vex.UltrasonicSensor.__init__ (   self,
  digitalnum,
  unit = UNIT_CM 
)

Member Function Documentation

◆ distance()

def vex.UltrasonicSensor.distance (   self)

Get the distance indicated by the sensor.

Returns
number

◆ set_unit_inch()

def vex.UltrasonicSensor.set_unit_inch (   self)

Set the distance unit to inches.

◆ set_unit_cm()

def vex.UltrasonicSensor.set_unit_cm (   self)

Set the distance unit to centimeters.

◆ set_unit_mm()

def vex.UltrasonicSensor.set_unit_mm (   self)

Set the distance unit to millimeters.