Main Content

readButton

Read whether button on EV3 brick is being pressed

Add-On Required: This feature requires the MATLAB Support Package for LEGO MINDSTORMS EV3 Hardware add-on.

Description

example

result = readButton(myev3,button) reads whether a specific button on the EV3 is being pressed, and returns the status as a logical value:

  • 0 means not pressed.

  • 1 means pressed.

Examples

collapse all

Read the status of the center button on an EV3 brick.

Create a connection to the EV3 brick called myev3.

myev3 = legoev3;

Hold down the center button on the EV3 and read the status of the button.

result = readButton(myev3,'center')
result =

     1

Release the center button on the EV3 and read the status of the button.

result = readButton(myev3,'center')
result =

     0

Input Arguments

collapse all

Connection to EV3 brick, specified as a string that represents the object created using legoev3.

Example: myev3

Data Types: char

Position of the button.

Example: 'up'

Data Types: char

Output Arguments

collapse all

The status of the button, returned as a logical value. 0 indicates not pressed. 1 indicates pressed.