Sensor
(varargin)¶High-level class to work with sensors.
The Sensor-class facilitates the communication with sensors. This mainly consists of reading the sensor's type and current value in a specified mode.
Notes
mode
¶DeviceMode.{Type} – Sensor mode in which the value will be read. By default, mode is set to DeviceMode.Default.Undefined. See also type
. [WRITABLE]
Once a physical sensor is connected to the port and the physical Brick is connected to the EV3-object, the allowed mode and the default mode for a Sensor-object are the following (depending on the sensor type):
debug
¶bool – Debug turned on or off. In debug mode, everytime a command is passed to the sublayer ('communication layer'), there is feedback in the console about what command has been called. [WRITABLE]
value
¶numeric – Value read from hysical sensor. What the value represents depends on
mode
. [READ-ONLY]
type
¶DeviceType – Type of physical sensor connected to the port. Possible types are: [READ-ONLY]
reset
(sensor)¶Resets sensor value.
Notes
setProperties
(sensor, varargin)¶Sets multiple Sensor properties at once using MATLAB's inputParser.
Parameters: |
|
---|
Example
b = EV3(); %
b.connect('bt', 'serPort', '/dev/rfcomm0'); %
b.sensor1.setProperties('debug', 'on', 'mode', DeviceMode.Color.Ambient); %
% Instead of: b.sensor1.debug = 'on';
% b.sensor1.mode = DeviceMode.Color.Ambient;