Documentation Center

  • Trial Software
  • Product Updates



Output state of touch sensor


Simulink Support Package for LEGO MINDSTORMS NXT Hardware


This block outputs the state of the LEGO MINDSTORMS 9843 Touch Sensor: 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 Touch Sensor

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

  2. Connect the Touch block to the LCD block, as shown.

  3. Connect the touch sensor to Port 1 on the NXT brick.

  4. Prepare and run the model on the NXT brick.

  5. Observe the state of the touch sensor on the LCD display while you press and release the touch sensor.

Dialog Box

NXT brick input port

Select the NXT 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.

See Also


External Web Sites

Was this topic helpful?