public class EV3UltrasonicSensor extends UARTSensor
Supported modes | |||
---|---|---|---|
Mode name | Description | unit(s) | Getter |
Distance | Measures distance to an object in front of the sensor | Meter | getDistanceMode() |
Listen | Listens for other ultrasonic sensors | Boolean | getListenMode() |
Sensor configuration
The sensor can be switched off and on using the enable()
and
disable()
methods. Disabling the sensor also shuts down the lights.
See Sensor Product page
See The
leJOS sensor framework
See leJOS conventions for
SampleProviders
currentMode, port
modes
Constructor and Description |
---|
EV3UltrasonicSensor(Port port)
Create the Ultrasonic sensor class.
|
EV3UltrasonicSensor(UARTPort port)
Create the Ultrasonic sensor class.
|
Modifier and Type | Method and Description |
---|---|
void |
disable()
Disable the sensor.
|
void |
enable()
Enable the sensor.
|
SampleProvider |
getDistanceMode()
Lego EV3 Ultrasonic sensor, Distance mode
Measures distance to an object in front of the sensor |
SampleProvider |
getListenMode()
Lego EV3 Ultrasonic sensor, Listen mode
Listens for the presence of other ultrasonic sensors. |
protected void |
init() |
boolean |
isEnabled()
Indicate that the sensor is enabled.
|
switchMode
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, sampleSize, setCurrentMode, setCurrentMode, setModes
close, releaseOnClose
public EV3UltrasonicSensor(Port port)
port
- public EV3UltrasonicSensor(UARTPort port)
port
- protected void init()
public SampleProvider getListenMode()
Size and content of the sample
The sample contains one elements indicating the presence of another ultrasonic sensor.
A value of 1 indicates that the sensor detects another ultrasonic sensor.
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 sensor.
unit).
public void enable()
public void disable()
public boolean isEnabled()