Main Content

NXT Touch Sensor

Detect status of EV3 brick NXT touch sensor

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

  • Lego NXT Touch Sensor block

Libraries:
Simulink Support Package for LEGO MINDSTORMS EV3 Hardware / NXT Sensors

Description

Use the NXT Touch Sensor block to detect whether the NXT touch sensor connected to the LEGO® MINDSTORMS® EV3 brick is pressed or not.

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

Examples

expand all

This example shows how to read the status of the NXT touch sensor connected to the EV3 brick on a display.

Open the legoev3nxtlib block library and copy the NXT Touch Sensor as described in Open Block Library for LEGO MINDSTORMS EV3 Hardware.

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

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

NXT Touch Sensor model

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

Ports

Output

expand all

The block outputs the status of the LEGO MINDSTORMS EV3 NXT touch sensor.

  • 0 — Indicates that the NXT touch sensor is not pressed.

  • 1 — Indicates that the NXT touch sensor is pressed.

Data Types: uint8

Parameters

expand all

Select the EV3 brick input port to which the NXT touch sensor is connected. Avoid assigning multiple devices to the same input port.

Specify the frequency of how often the block reads the NXT touch sensor status. Shorter sample times, such as 0.01, may produce unreliable measurements.

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

Version History

Introduced in R2012a