Migrate docs from the other repo
This commit is contained in:
47
docs/reference/js/lessons/screen-wipe/activity.md
Normal file
47
docs/reference/js/lessons/screen-wipe/activity.md
Normal file
@ -0,0 +1,47 @@
|
||||
# screen wipe activity
|
||||
|
||||
Clear the screen by pressing buttons on the BBC micro:bit #docs #tutorials #stepByStep
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
### @video td/videos/screen-wipe-0
|
||||
|
||||
This activity will teach how to clear the screen by pressing button ``A`` on the BBC micro:bit.
|
||||
|
||||
### ~
|
||||
|
||||
You can use the `basic->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.
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
. . . . . # # # # # # # # # # . . . . .
|
||||
. . . . . # # # # # # # # # # # # # # #
|
||||
. . . . . . . . . . . . . . . # # # # #
|
||||
`, 400) // ***
|
||||
```
|
||||
|
||||
We add another line of code that registers an **event handler** on the `input->on button pressed(A)` and calls `basic->clear screen`.
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
. . . . . # # # # # # # # # # . . . . .
|
||||
. . . . . # # # # # # # # # # # # # # #
|
||||
. . . . . . . . . . . . . . . # # # # #
|
||||
`, 400)
|
||||
input.onButtonPressed("A", () => {
|
||||
basic.clearScreen() // ***
|
||||
}) // ***
|
||||
```
|
||||
|
||||
Run the script in the simulator or on the BBC micro:bit to see how this works!
|
||||
|
||||
### ~avatar boothing
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/microbit/lessons/screen-wipe/challenges)!
|
||||
|
||||
### ~
|
||||
|
73
docs/reference/js/lessons/screen-wipe/challenges.md
Normal file
73
docs/reference/js/lessons/screen-wipe/challenges.md
Normal file
@ -0,0 +1,73 @@
|
||||
# screen wipe challenges
|
||||
|
||||
Coding challenges for the screen wipe tutorial. #docs
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the [screen wipe](/microbit/lessons/screen-wipe) activity and your code will look like this:
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
. . . . . # # # # # # # # # # . . . . .
|
||||
. . . . . # # # # # # # # # # # # # # #
|
||||
. . . . . . . . . . . . . . . # # # # #
|
||||
`, 400)
|
||||
input.onButtonPressed("A", () => {
|
||||
basic.clearScreen()
|
||||
})
|
||||
```
|
||||
|
||||
**Challenge 1**
|
||||
|
||||
Create an event handler for Button "B".
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
. . . . . # # # # # # # # # # . . . . .
|
||||
. . . . . # # # # # # # # # # # # # # #
|
||||
. . . . . . . . . . . . . . . # # # # #
|
||||
`, 400)
|
||||
input.onButtonPressed("A", () => {
|
||||
basic.clearScreen()
|
||||
})
|
||||
input.onButtonPressed("B", () => {
|
||||
})
|
||||
```
|
||||
|
||||
**Challenge 2**
|
||||
|
||||
### @video td/videos/screen-wipe-2
|
||||
|
||||
Replay the animation when the "B" button is pressed by typing in `basic->show animation(..., 400)`.
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
. . . . . # # # # # # # # # # . . . . .
|
||||
. . . . . # # # # # # # # # # # # # # #
|
||||
. . . . . . . . . . . . . . . # # # # #
|
||||
`, 400)
|
||||
input.onButtonPressed("A", () => {
|
||||
basic.clearScreen()
|
||||
})
|
||||
input.onButtonPressed("B", () => {
|
||||
basic.showAnimation(`
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
. . . . . # # # # # # # # # # . . . . .
|
||||
. . . . . # # # # # # # # # # # # # # #
|
||||
. . . . . . . . . . . . . . . # # # # #
|
||||
`, 400) // ***
|
||||
})
|
||||
```
|
||||
|
||||
**Challenge 3**
|
||||
|
||||
Show an animation that scrolls back up when you press button "B".
|
||||
|
||||
* tap the `run` button to view your final product!
|
45
docs/reference/js/lessons/screen-wipe/quiz-answers.md
Normal file
45
docs/reference/js/lessons/screen-wipe/quiz-answers.md
Normal file
@ -0,0 +1,45 @@
|
||||
# screen wipe quiz answers
|
||||
|
||||
clear the screen by pressing the "A" button after an animation has been played #LED #screen #variables #docs
|
||||
|
||||
This is the answer key for the [screen wipe quiz](/microbit/lessons/screen-wipe/quiz).
|
||||
|
||||
## 1. What does the function "clear screen" do on the BBC micro:bit?
|
||||
|
||||
This function turns off all the LED lights on the LED screen.
|
||||
|
||||
## 2. Write the line of code that creates and displays this animation.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
# # # # . # # # # # . . . . . . . . . .
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
. . . . . # # # # # # # # # # . . . . .
|
||||
. . . . . # # # # # # # # # # # # # # #
|
||||
. . . . . . . . . . . . . . . # # # # #
|
||||
`, 400)
|
||||
```
|
||||
|
||||
## 3. Write the condition that will detect when the BBC micro:bit is shaken.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
})
|
||||
```
|
||||
|
||||
## 4. Write the code that will clear an animation from the screen after shaking the BBC micro:bit.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
basic.clearScreen()
|
||||
})
|
||||
```
|
||||
|
32
docs/reference/js/lessons/screen-wipe/quiz.md
Normal file
32
docs/reference/js/lessons/screen-wipe/quiz.md
Normal file
@ -0,0 +1,32 @@
|
||||
# screen wipe quiz
|
||||
|
||||
clear the screen by pressing the "A" button after an animation has been played #LED #screen #variables #docs #button
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [screen wipe tutorial](/microbit/lessons/screen-wipe/tutorial)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. What does the function "clear screen" do on the BBC micro:bit?
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. We can show all of these images in one line of code. What method can we use to do this?
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
## 3. How can the BBC micro:bit detect when it is shaken?
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 4. Write the code that will clear an animation from the screen after shaking the BBC micro:bit.
|
||||
|
||||
<br/>
|
||||
|
Reference in New Issue
Block a user