Touch Sensor Block

The Touch Sensor block gets data from the Touch Sensor. You can test whether the Touch Sensor is Pressed, Released, or Bumped, and get a Logic (True or False) output.

See Using the Touch Sensor for more information about how the Touch Sensor works, the data that it provides, and programming examples.
Tips and Tricks
The Touch Sensor block outputs data with a Data Wire. See Using the Touch Sensor for other ways to use the Touch Sensor that don’t require a data wire.
Choose the Sensor Port and Mode


Port Selector
Mode Selector
Inputs
Outputs


Use the Port Selector on the top of the block to make sure that the sensor port number (1, 2, 3, or 4) matches the port on the EV3 Brick that the Touch Sensor is connected to.

Use the Mode Selector to select the mode for the block. The Inputs and Outputs available will change depending on the mode.
Modes
Measure – State


The Measure – State mode outputs the state of the Touch Sensor in the State output. The State is True if the Touch sensor is currently pressed in, and False if not.
Compare – State


In the Compare – State mode, you can choose which state of the Touch Sensor to test (Released, Pressed, or Bumped) in the State input. The True/False value of the selected state is output in the Compare Result. The current state of the sensor is output in Measured Value.
Inputs and Outputs
The inputs available for the Touch Sensor block will depend on the mode selected. You can enter the input values directly into the block. Alternatively, the input values can be supplied by Data Wires from the outputs of other Programming Blocks.
InputTypeAllowed ValuesNotes
State Numeric0 - 2State to test in Compare mode.
0 = Released
1 = Pressed
2 = Bumped
The outputs available will depend on the mode selected. To use an output, use a Data Wire to connect it to another Programming Block.
OutputTypeNotes
State LogicUsed in Measure mode.
True if the touch sensor is pressed, False if not.
Compare Result LogicThe value of the selected sensor state in Compare mode.
Measured Value NumericThe current sensor state in Compare mode.
0 = Released
1 = Pressed
2 = Bumped
Touch
Quick links