Documentation Center

  • Trials
  • Product Updates



Output state of button on NXT brick


Simulink Support Package for LEGO MINDSTORMS NXT Hardware


Get the state of the "middle orange" or "right arrow" button on the NXT brick: 1 while pressed and 0 while released.

If you run a simulation of a model that contains this block without the target hardware, this block outputs zeroes. See Block Produces Zeros or Does Nothing in Simulation.

Use the Button

Measure the voltage of the batteries in the NXT brick.

Open the legonxtlib block library and copy the blocks shown to a new model.

Connect the Button block to the LCD block, as shown.

Prepare and run the model on the NXT brick.

Press the orange button on the NXT brick, and observe 0 on the LCD display turn to 1.

Dialog Box


Select the button for which to output status. The options are Middle orange and Right arrow.

Sample time

Specify how often the block reads the state of the button.

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

See Also

| | | | | |

External Web Sites

Was this topic helpful?