Micro:Bit — button
There are two buttons on the front of your §micro:bit
Blocks you drop into the
on start container run once, when you turn your micro:bit on. Blocks dropped in
forever keep running… well, until the batteries last.
on button pressed allows you to add blocks that will run when – and only when – one of the micro:bit’s buttons is pressed. Try the example above.
Let’s make a light switch – what could be more useful?
Try combining an
on button pressed container with
digital write pin to turn an LED on. The example on the
led page will help you.
on pin pressedevent handler block. See that link for how to use yourself as the switch… or you could try making a switch out of bits of foil.