input.onPinPressed(TouchPin.P0, function () {
})
This tutorial will help you solve your first microbit mystery!
We need to write code to check whether the user is correct if they touch pin #0.
Put a 'check door'
custom block inside of the 'on pin P0 pressed' block that's already on your screen.
input.onPinPressed(TouchPin.P0, function () {
custom.checkDoor(0)
})
Let's write some code to check pin P1.
Do the same thing that we did for P0, but make sure you're checking door 1.
input.onPinPressed(TouchPin.P1, function () {
custom.checkDoor(1)
})
Do the same thing for P2, but check door 2.
input.onPinPressed(TouchPin.P2, function () {
custom.checkDoor(2)
})
Did writing this code help you figure out what you need to do to solve the mystery?
Try running the code here and see if you can answer the mystery!
For extra fun, click |Download|
to transfer your code to your microbit!