A touch sensor is a simple push button that can either be pressed or released.
The EV3 Touch Sensor is no different. It will return a Boolean type value (true or false) depending on its state:
|Touch Sensor State||Returned Value|
Here is an example code:
In the example above, the until condition refers to the touch sensor state.
The loop will continue until the condition is true, meaning until the touch sensor is pressed.
That is just one way to drive the robot forward until the touch sensor hits an obstacle.