Main Content

Button

Detect button press on EV3 brick

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

Library

Simulink® Support Package for LEGO® MINDSTORMS® EV3 Hardware

  • Button block

Description

Detect whether a specific the EV3 Brick Button is being pressed:

  • 0 = Not pressed

  • 1 = Pressed

You can configure the block to detect the Center, Left, Right, Up, or Down button.

You cannot configure the block to detect the Back button because the EV3 brick reserves the Back button for stopping programs and shutting down.

The block output emits values as uint8.

During simulations without hardware, this block emits zeros. See Block Produces Zeros or Does Nothing in Simulation.

Parameters

Button

Select one of the EV3 Brick Buttons: Center, Left, Right, Up, or Down.

Sample time

Specify how often the block reads the state of the button. The default value is 0.1.

Smaller values require the processor to complete the same number of instructions in less time, which can cause task overruns.