- This article is about the EV3 Extension block. For the micro:bit Extension block, see () Button Pressed? (block).
Button () Pressed? | |
<button ( v) pressed? :: ev3 > | |
Category | LEGO MINDSTORMS EV3 |
Type | Boolean |
Introduced in | 3.0 |
The button () pressed? block is a boolean block and a LEGO MINDSTORMS EV3 block. Its options are "1", "2", "3", and "4". The block returns whether or not the button connected to the specified port on the EV3 unit is pressed.
Example Uses
- Sensing when a correct answer in a quiz is chosen.
when I receive [level 1 v] say [Which of these is the correct answer?] if <button (2 v) pressed?::ev3> then say [Correct!] for (1) seconds broadcast (level 2 v) else say [Incorrect. Please try again.] for (2) seconds broadcast (level 1 v) end
- Sensing when an option is chosen in a choose your own story game.
. . . say [Suggest a location where he may be.] if <button (1 v) pressed?::ev3> then say [Going to the cafe!] for (2) seconds broadcast (cafe v) end if <button (2 v) pressed?::ev3> then say [Running to the store!] for (2) seconds broadcast (store v) end if <button (3 v) pressed?::ev3> then say [The park is a good idea!] for (2) seconds broadcast (park v) end if <button (4 v) pressed?::ev3> then say [That is a good idea!] for (2) seconds broadcast (forest v) end