is Pressed
Check to see if a touch sensor is currently pressed or not.
sensors.touch1.isPressed()
Returns
- a boolean value that is
true
if the sensor is currently pressed. It’sfalse
if the sensor is not pressed.
Example
If the touch sensor touch 1
is pressed, show a green
status light. Otherwise, set the status light to orange
.
forever(function () {
if (sensors.touch1.isPressed()) {
brick.setStatusLight(StatusLight.Green)
} else {
brick.setStatusLight(StatusLight.Orange)
}
})