public class EV3UltrasonicSensor extends BaseSensor
Sensor configuration
The sensors can be switched off and on using the enable()
and
disable()
methods. Disabling the sensors also shuts down the lights.
See Sensor Product page
See The
leJOS sensors framework
See leJOS conventions for
SampleProviders
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
LEGO_EV3_US |
static float |
MAX_RANGE |
static float |
MIN_RANGE |
private static java.lang.String |
MODE_DISTANCE |
private static java.lang.String |
MODE_LISTEN |
private static java.lang.String |
MODE_SINGLE_MEASURE |
currentMode, modes, SWITCH_DELAY
LEGO_ANALOG_SENSOR, LEGO_I2C, LEGO_UART_SENSOR, SENSOR_MODE, SENSOR_MODES
ADDRESS, CURRENT_PLATFORM, DEVICE, ev3DevProperties, LEGO_PORT, LEGO_SENSOR, MODE, PATH_DEVICE
Constructor and Description |
---|
EV3UltrasonicSensor(Port portName)
Create the Ultrasonic sensors class.
|
Modifier and Type | Method and Description |
---|---|
void |
disable()
Disable the sensor.
|
void |
enable()
Enable the sensor.
|
SampleProvider |
getDistanceMode()
Lego EV3 Ultrasonic sensors, Distance mode
Measures distance to an object in front of the sensors |
SampleProvider |
getListenMode()
Lego EV3 Ultrasonic sensors, Listen mode
Listens for the presence of other ultrasonic sensors. |
boolean |
isEnabled()
Indicate that the sensors is enabled.
|
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, getSystemMode, sampleSize, setCurrentMode, setCurrentMode, setModes, switchMode
detect, getIntegerAttribute, getStringAttribute, setIntegerAttribute, setStringAttribute
private static final java.lang.String LEGO_EV3_US
public static float MIN_RANGE
public static float MAX_RANGE
private static final java.lang.String MODE_DISTANCE
private static final java.lang.String MODE_LISTEN
private static final java.lang.String MODE_SINGLE_MEASURE
public EV3UltrasonicSensor(Port portName)
portName
- portpublic SampleProvider getListenMode()
Size and content of the sample
The sample contains one elements indicating the presence of another ultrasonic sensors.
A value of 1 indicates that the sensors detects another ultrasonic sensors.
public SampleProvider getDistanceMode()
Size and content of the sample
The sample contains one elements representing the distance (in metres) to an object in front of the sensors.
unit).
public void enable()
Note: this function switches the sensor mode.
This means that reads from SensorModes different from the one
returned by getDistanceMode() will be invalid.
See GenericMode.fetchSample(float[], int)
public void disable()
Note: this function switches the sensor mode.
This means that reads from SensorModes will be invalid
until enable() or get*Mode() is called.
See GenericMode.fetchSample(float[], int)
public boolean isEnabled()