Migrate docs from the other repo
This commit is contained in:
90
docs/lessons/screen-wipe/activity.md
Normal file
90
docs/lessons/screen-wipe/activity.md
Normal file
@ -0,0 +1,90 @@
|
||||
# screen wipe blocks activity
|
||||
|
||||
Clear the screen by pressing buttons on the micro:bit
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
### @video td/videos/screen-wipe-0
|
||||
|
||||
This activity will teach how to clear the screen by pressing button A on the micro:bit.
|
||||
|
||||
### ~
|
||||
|
||||
You can use the clear screen` function to turn off all the LED on the screen. Let's illustrate this concept with a small script where the user has to press the button A to turn off the screen. Let's start by adding the code to show an animation.
|
||||
|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
. . . . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
# # # # #
|
||||
# # # # #
|
||||
. . . . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
# # # # #
|
||||
# # # # #
|
||||
`)
|
||||
```
|
||||
|
||||
We add another line of code that registers an *event handler* `on button pressed` *A* and calls `clear screen`.
|
||||
|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
. . . . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
# # # # #
|
||||
# # # # #
|
||||
. . . . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
# # # # #
|
||||
# # # # #
|
||||
`)
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.clearScreen()
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
*Run* the script in the simulator or on the micro:bit to see how this works!
|
||||
|
||||
### ~avatar boothing
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/microbit/lessons/screen-wipe/challenges)!
|
||||
|
||||
### ~
|
||||
|
Reference in New Issue
Block a user