This article or section documents something only available on the Raspberry Pi version of Scratch 3.0.
When Button () is ()
when button (0 v) is [pressed v]:: extension hat
Category Raspberry Pi Simple Electronics
Type Hat
Introduced in 3.0

The when button () is () block is a Raspberry Pi Simple Electronics block and a hat block. In the first option, numbers 0 through 27 can be inputted, with each number representing a GPIO pin. The second options are "pressed" and "released". The block activates when the specified LED is pressed or released, depending on the input.

Example uses

  • Making a sprite say something when a button is pressed
When button (0 v) is [pressed v]:: extension hat
say [Hey, that tickles!]
When button (0 v) is [released v]:: extension hat
say [I'm good now.]
Cookies help us deliver our services. By using our services, you agree to our use of cookies.