legoev3

Connection to EV3 brick

Description

This object represents a connection to an EV3 brick. To connect to the EV3 brick, create this object using the legoev3 function. To interact with peripherals on the EV3 brick, such as the speaker, LCD, buttons, or status light, use this object with the functions listed in Object Functions. To connect to sensors and motors, use this object with the following sensor functions: colorSensor, gyroSensor, irSensor, sonicSensor, touchSensor, or motor.

Creation

To connect to, and create an object that represents, the EV3 brick, use legoev3. For example:

myev3 = legoev3('usb')
myev3 = 

  legoev3 with properties:

      FirmwareVersion: 'V1.03E'
           HardwareID: []
            IPAddress: []
    CommunicationType: 'USB'
         BatteryLevel: 100
     ConnectedSensors: {'touch'  'infrared'  'color'  'sonic'}

The resulting legoev3 object, myev3, displays EV3 brick properties, such as a list of connected sensors.

To interact with built-in EV3 peripherals, use the legoev3 object with clear, writeLCD, clearLCD, playTone, beep, readButton, and writeStatusLight. For example:

beep(myev3)

To connect to sensors or motors that are attached to the EV3 brick, use the legoev3 object with the colorSensor, gyroSensor, irSensor, sonicSensor, touchSensor, or motor functions. For example:

mysonicsensor = sonicSensor(myev3);

Properties

expand all

This property is read-only.

EV3 firmware version, returned as a string.

Example: 'V1.03E'

Data Types: char

This property is read-only.

Unique hardware ID, returned as a string.

Example: '00165340e49b'

Data Types: char

This property is read-only.

IP address when connecting over a wireless network, returned as a string.

Example: '192.168.1.2'

Data Types: char

This property is read-only.

Communication type, returned as a string.

Example: 'USB'

Data Types: char

This property is read-only.

Battery level percentage, returned as an int8 value.

Example: 68

Data Types: double

This property is read-only.

List of connected sensors, returned as a cell array of strings. '' means no connected sensors.

Example: {'touch' 'infrared' 'color' 'sonic'}

Data Types: cell

Object Functions

legoev3Create connection to EV3 brick
clearRemove items from workspace, freeing up system memory
writeLCDWrite characters to LCD on EV3 brick
clearLCDClear characters from LCD on EV3 brick
playTonePlay tones from speaker on EV3 brick
beepPlay beep from speaker on EV3 brick
readButtonRead whether button on EV3 brick is being pressed
writeStatusLightControl color and mode of status light on EV3 brick