Main Content

readButton

Read whether button on EV3 brick is being pressed

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:

  • 0means not pressed.

  • 1means pressed.

Examples

collapse all

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

Create a connection to the EV3 brick calledmyev3.

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 usinglegoev3.

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.0indicates not pressed.1indicates pressed.