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 | Class and Description |
---|---|
private class |
EV3UltrasonicSensor.DistanceMode |
private class |
EV3UltrasonicSensor.ListenMode
Represents a Ultrasonic sensors in listen mode
|
Modifier and Type | Field and Description |
---|---|
private static int |
DISABLED |
private static java.lang.String |
LEGO_EV3_US |
currentMode, currentModeS, modes, SWITCH_DELAY
LEGO_ANALOG_SENSOR, LEGO_UART_SENSOR, SENSOR_MODE, SENSOR_MODES
ADDRESS, DEVICE, LEGO_PORT, LEGO_SENSOR, MODE, PATH_DEVICE
DEVICE_ROOT_PATH
BRICKPI, EV3BRICK, PISTORMS
Constructor and Description |
---|
EV3UltrasonicSensor(java.lang.String portName)
Create the Ultrasonic sensors class.
|
Modifier and Type | Method and Description |
---|---|
void |
disable()
Disable the sensors.
|
void |
enable()
Enable the sensors.
|
SampleProvider |
getDistanceMode()
Lego EV3 Ultrasonic sensors, Distance mode
Measures distance to an object in front of the sensors Size and content of the sample The sample contains one elements representing the distance (in metres) to an object in front of the sensors. |
SampleProvider |
getListenMode()
Lego EV3 Ultrasonic sensors, Listen mode
Listens for the presence of other ultrasonic sensors. |
private void |
init() |
boolean |
isEnabled()
Indicate that the sensors is enabled.
|
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, sampleSize, setCurrentMode, setCurrentMode, setModes, switchMode, switchMode
detect, getIntegerAttribute, getStringAttribute, setIntegerAttribute, setStringAttribute
getMotorPort, getPlatform, getSensorPort
private static final int DISABLED
private static final java.lang.String LEGO_EV3_US
public EV3UltrasonicSensor(java.lang.String portName)
portName
- portprivate void init()
public 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()
public void disable()
public boolean isEnabled()