2e9cb3c43b
* Fix tutorial authoring for getting started Remove extra new lines * Fix other tutorials
1.6 KiB
1.6 KiB
Smiley Buttons
Step 1
Place a ||input:on button pressed||
block to run code when button A is pressed.
input.onButtonPressed(Button.A, () => {
});
Step 2
Place a ||basic:show leds||
block inside ||input:on button pressed||
to display a smiley on the screen.
input.onButtonPressed(Button.A, () => {
basic.showLeds(`
# # . # #
# # . # #
. . . . .
# . . . #
. # # # .`
);
});
Step 3
Click |Download|
to transfer your code in your @boardname@ and try pressing button A.
Step 4
Add ||input:on button pressed||
and ||basic:show leds||
blocks to display a frowney when button B is pressed.
input.onButtonPressed(Button.B, () => {
basic.showLeds(`
# # . # #
# # . # #
. . . . .
. # # # .
# . . . #`
);
});
Step 5
Click |Download|
to transfer your code in your @boardname@ and try pressing button A or B.
Step 6
Add a secret mode where A
and B
are pressed together. In that case, add multiple ||basic:show leds||
blocks to create an animation...
input.onButtonPressed(Button.AB, () => {
basic.showLeds(`
. . . . .
# . # . .
. . . . .
# . . . #
. # # # .
`)
basic.showLeds(`
. . . . .
. . # . #
. . . . .
# . . . #
. # # # .
`)
})
Step 7
Click |Download|
to transfer your code in your @boardname@
and show it off to your friends!