EV3
(varargin)¶High-level class to work with physical bricks.
This is the 'central' class (from user's view) when working with this toolbox. It delivers a convenient interface for creating a connection to the brick and sending commands to it. An EV3-object creates 4 Motor- and 4 Sensor-objects, one for each port.
Notes
debug
¶numeric in {0,1,2} – Debug mode. [WRITABLE]
batteryMode
¶string in {'Percentage', 'Voltage'} – Mode for reading battery charge. See also batteryValue
. [WRITABLE]
batteryValue
¶numeric – Current battery charge. Depending on batteryMode, the reading is either in percentage or voltage. See also batteryMode
. [READ-ONLY]
isConnected
¶bool – True if virtual brick-object is connected to physical one. [READ-ONLY]
Example
% This example expects a motor at port A and a (random) sensor at port 1
b = EV3(); %
b.connect('usb'); %
ma = b.motorA; %
ma.setProperties('power', 50, 'limitValue', 720); %
ma.start(); %
% fun
ma.waitFor(); %
disp(b.sensor1.value); %
b.beep(); %
delete b; %
beep
(ev3)¶Plays a 'beep'-tone on brick.
Notes
Example
b = EV3(); %
b.connect('bt', 'serPort', '/dev/rfcomm0'); %
b.beep(); %
connect
(ev3, varargin)¶Connects EV3-object and its Motors and Sensors to physical brick.
Parameters: |
|
---|
Example
% Setup bluetooth connection via com-port 0
b = EV3(); %
b.connect('bt', 'serPort', '/dev/rfcomm0'); %
% Setup usb connection, beep when connection has been established
b = EV3(); %
b.connect('usb', 'beep', 'on', ); %
See also ISCONNECTED / isConnected
disconnect
(ev3)¶Disconnects EV3-object and its Motors and Sensors from physical brick.
Notes
Example
b = EV3(); %
b.connect('bt', 'serPort', '/dev/rfcomm0'); %
% do stuff
b.disconnect(); %
playTone
(ev3, volume, frequency, duration)¶Plays tone on brick.
Parameters: |
|
---|
Example
b = EV3(); %
b.connect('bt', 'serPort', '/dev/rfcomm0'); %
b.playTone(40, 5000, 1000); % Plays tone with 40% volume and 5000Hz for 1
second.
setProperties
(ev3, varargin)¶Set multiple EV3 properties at once using MATLAB's inputParser.
Parameters: |
|
---|
Example
b = EV3(); %
b.connect('bt', 'serPort', '/dev/rfcomm0'); %
b.setProperties('debug', 'on', 'batteryMode', 'Voltage'); %
% Instead of: b.debug = 'on'; b.batteryMode = 'Voltage'; %
See also EV3.DEBUG, EV3.BATTERYMODE / debug
, batteryMode
stopAllMotors
(ev3)¶Sends a stop-command to all motor-ports.
stopTone
(ev3)¶Stops tone currently played.
Example
b = EV3(); %
b.connect('bt', 'serPort', '/dev/rfcomm0'); %
b.playTone(10,100,100000000); % Accidentally given wrong tone duration :)
b.stopTone(); % Stops tone immediately.
tonePlayed
(ev3)¶Tests if tone is currently played.
Returns: | status – True if a tone is being played |
---|---|
Return type: | bool |