Main Content

NXT Touch Sensor

Reads state of NXT touch sensor

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/ NXT Sensors

  • NXT Touch Sensor block

Description

The NXT Touch Sensor block detects whether the NXT touch sensor connected to the LEGO MINDSTORMS EV3 brick is being pressed:

  • 0 = Not pressed

  • 1 = Pressed

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

Use the Touch Sensor

  1. Open the legoev3nxtlib block library and copy the NXT Touch Sensor block to a new model.

  2. Open the legoev3lib block library and copy the Display block to the same model and connect these blocks.

  3. Connect the touch sensor to port 1 of the EV3 brick.

  4. Prepare and run the model on the EV3 brick as described in Run Model on EV3 Hardware. Observe the state of the touch sensor on the LCD display of the EV3 brick while you press and release the touch sensor.

Parameters

EV3 brick input port number

Select the EV3 sensor port to which the sensor is connected. Avoid assigning multiple devices to the same port. The options are 1, 2, 3, or 4.

Sample time

Specify how often the block reads sensor values.

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

Version History

Introduced in R2018a