legoev3

Create connection to EV3 brick

Syntax

myev3 = legoev3
myev3 = legoev3(communicationtype)
myev3 = legoev3(communicationtype,ipaddress,id)
myev3 = legoev3(communicationtype,comport)

Description

example

myev3 = legoev3 creates a connection to an EV3 brick, myev3, that uses the same settings as the previous connection.

example

myev3 = legoev3(communicationtype) creates a connection to an EV3 brick using a specific type of communications.

example

myev3 = legoev3(communicationtype,ipaddress,id) creates a connection to an EV3 brick using a type of communications that requires the IP address and ID of the EV3 brick.

example

myev3 = legoev3(communicationtype,comport) creates a connection to an EV3 brick using a type of communications that requires a COM port number.

Examples

collapse all

If you have connected to the EV3 brick previously, you can reconnect without specifying any details.

myev3 = legoev3;

You can communicate with the EV3 brick over a USB cable.

Using the supplied USB cable, connect the host computer to the EV3 brick.

In the MATLAB Command Window, connect over USB.

myev3 = legoev3('USB');

You can communicate with the EV3 brick over a wireless network connection.

Set up and configure a wireless network connection.

In the Command Window, connect using a wireless network. Specify the IP address and ID of the EV3 brick.

myev3 = legoev3('WiFi','192.168.1.2','00165340e49b');

You can communicate with the EV3 brick over a Bluetooth® connection.

Set up and configure a Bluetooth connection.

In the MATLAB® Command Window, create a connection from a host computer running Windows® to an EV3 brick over Bluetooth. Specify the COM port number.

myev3 = legoev3('Bluetooth','COM3');

You can communicate with the EV3 brick over a Bluetooth connection.

On Mac OS, Set up and configure a Bluetooth connection to the EV3 brick.

Open Terminal in Mac OS and enter:

ls /dev/tty*
/dev/tty.EV3-SerialPort

The command response gives the name of the Bluetooth connection from Mac OS to the EV3 Brick

In the MATLAB Command Window, create a connection from a host computer running Mac OS to an EV3 brick over Bluetooth. Specify the COM port number.

myev3 = legoev3('Bluetooth','/dev/tty.EV3-SerialPort');

Input Arguments

collapse all

Communication types for the connection between the host computer and the EV3 brick, specified as a string.

Example: 'WiFi'

Data Types: char

IPv4 address of the EV3 brick, specified as a string. This value is available in the EV3 interface under Brick Info.

Example: '192.168.1.2'

Data Types: char

Hardware ID of EV3 brick, specified as a string. This value is available in the EV3 interface under Brick Info.

Example: '00165340e49b'

Data Types: char

COM port or serial device on host computer, specified as a string.

Example: 'COM3'

Example: '/dev/tty.EV3-SerialPort'

Data Types: char

Output Arguments

collapse all

Connection to EV3 brick, returned as an object handle. You can use this connection to:

  • Interact with peripherals on the EV3 brick, such as the LCD, speaker, status light, and buttons.

  • Create connections to sensors and motors that are attached to the EV3 brick.