Knowledge Base

Get Touch is Pressed Block

output-onlinepngtools__231_.png  This block works for both EV3 Robot and Ruby Robot!  output-onlinepngtools__101_.png

The Get Touch is Pressed block allows you to sample the state of the robot's touch sensor/s. It is very useful for touching objects and knowing when to stop driving!  


In this example code for EV3 Robot, the loop will continue until the condition is true, meaning until the touch sensor is pressed. Once it is pressed, the robot will stop.


In this example code for Ruby Robot, the robot will drive forward until the touch sensor is pressed, and once it is, the robot will drive backward for half a second before turning 90 degrees to the right.



Note: Get Touch is Pressed block can also be used in a comparison block and compared to a true/false block set to 'true'. The result will be the same.



See also:

Touch Sensor

Wait Until Touch (EV3)


Was this article helpful?
0 out of 0 found this helpful


Please sign in to leave a comment.