Migrate docs from the other repo
This commit is contained in:
30
docs/reference/js/lessons/smiley/activity.md
Normal file
30
docs/reference/js/lessons/smiley/activity.md
Normal file
@ -0,0 +1,30 @@
|
||||
# smiley activity
|
||||
|
||||
Learn to design a blinking image. #docs #microbit
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
### @video td/videos/smiley-0
|
||||
|
||||
Welcome! This tutorial will help you make a smiley face blink. Let's get started!
|
||||
|
||||
### ~
|
||||
|
||||
Create an animation with a frame displaying a smiley face and the next frame with no LEDs lit up. This will make it look like the smiley face is blinking as the display switches between frames.
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
. # . # . . . . . .
|
||||
. # . # . . . . . .
|
||||
. . . . . . . . . .
|
||||
# . . . # . . . . .
|
||||
. # # # . . . . . .
|
||||
`, 400) // ***
|
||||
```
|
||||
|
||||
### ~avatar boothing
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/microbit/lessons/smiley/challenges)!
|
||||
|
||||
### ~
|
||||
|
67
docs/reference/js/lessons/smiley/challenges.md
Normal file
67
docs/reference/js/lessons/smiley/challenges.md
Normal file
@ -0,0 +1,67 @@
|
||||
# smiley challenges
|
||||
|
||||
Coding challenges for the smiley tutorial. #docs
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the [smiley activity](/microbit/lessons/smiley/activity) and your code will look like this:
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
. # . # . . . . . .
|
||||
. # . # . . . . . .
|
||||
. . . . . . . . . .
|
||||
# . . . # . . . . .
|
||||
. # # # . . . . . .
|
||||
`, 400)
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
What if we want to make the face to frown when button `A` is pressed?
|
||||
|
||||
Let's make add code that will run when button `A` is pressed!
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
. # . # . . . . . .
|
||||
. # . # . . . . . .
|
||||
. . . . . . . . . .
|
||||
# . . . # . . . . .
|
||||
. # # # . . . . . .
|
||||
`, 400)
|
||||
input.onButtonPressed("A", () => {
|
||||
}) // ***
|
||||
```
|
||||
|
||||
### Challenge 2
|
||||
|
||||
### @video td/videos/smiley-2
|
||||
|
||||
Now, we want to show a frowny face when this button is pressed. Let's plot that image.
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
. # . # . . . . . .
|
||||
. # . # . . . . . .
|
||||
. . . . . . . . . .
|
||||
# . . . # . . . . .
|
||||
. # # # . . . . . .
|
||||
`, 400)
|
||||
input.onButtonPressed("A", () => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # # # .
|
||||
# . . . #
|
||||
`, 400) // ***
|
||||
})
|
||||
```
|
||||
|
||||
* Run your code to see if it works as expected.
|
||||
|
||||
### Challenge 3
|
||||
|
||||
When button `B` is pressed, let's change the sad face back to a happy face. To do this, begin by adding a condition for `input->on button pressed(B)`. Then show a smiley face inside the condition.
|
||||
|
78
docs/reference/js/lessons/smiley/quiz-answers.md
Normal file
78
docs/reference/js/lessons/smiley/quiz-answers.md
Normal file
@ -0,0 +1,78 @@
|
||||
# smiley quiz answers
|
||||
|
||||
#LED #screen #animation #docs
|
||||
|
||||
This is the answer key for the [smiley quiz](/microbit/lessons/smiley/quiz).
|
||||
|
||||
## 1. Define 'show animation' :
|
||||
|
||||
A function that will show a series of image frames on the LED screen, pausing the specified time after each frame.
|
||||
|
||||
## 2. Why is there an extra empty frame after the smiley face?
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
. # . # . . . . . .
|
||||
. # . # . . . . . .
|
||||
. . # . . . . . . .
|
||||
# . . . # . . . . .
|
||||
. # # # . . . . . .
|
||||
`, 400)
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
The extra empty frame creates a blinking smiley, allowing the BBC micro:bit to alternate between showing the smiley and the empty screen.
|
||||
|
||||
## 3. Change the delay shown from 400 milliseconds to 1000 milliseconds.
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
. # . # . . . . . .
|
||||
. # . # . . . . . .
|
||||
. . # . . . . . . .
|
||||
# . . . # . . . . .
|
||||
. # # # . . . . . .
|
||||
`, 400)
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
. # . # . . . . . .
|
||||
. # . # . . . . . .
|
||||
. . # . . . . . . .
|
||||
# . . . # . . . . .
|
||||
. # # # . . . . . .
|
||||
`, 1000)
|
||||
```
|
||||
|
||||
## 4. Now let's change the delay shown below from 400 milliseconds to 2.5 seconds.
|
||||
|
||||

|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
. # . # . . . . . .
|
||||
. # . # . . . . . .
|
||||
. . # . . . . . . .
|
||||
# . . . # . . . . .
|
||||
. # # # . . . . . .
|
||||
`, 400)
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
. # . # . . . . . .
|
||||
. # . # . . . . . .
|
||||
. . # . . . . . . .
|
||||
# . . . # . . . . .
|
||||
. # # # . . . . . .
|
||||
`, 2500)
|
||||
```
|
||||
|
54
docs/reference/js/lessons/smiley/quiz.md
Normal file
54
docs/reference/js/lessons/smiley/quiz.md
Normal file
@ -0,0 +1,54 @@
|
||||
# smiley quiz
|
||||
|
||||
make a smiley face blink #LED #screen #animation #docs
|
||||
|
||||
## Name
|
||||
|
||||
## 1. Describe what `basic->show animation` does
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Why is there an extra empty frame after the smiley face?
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
. # . # . . . . . .
|
||||
. # . # . . . . . .
|
||||
. . # . . . . . . .
|
||||
# . . . # . . . . .
|
||||
. # # # . . . . . .
|
||||
`, 400)
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Change the delay shown from 400 milliseconds to 1000 milliseconds.
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
. # . # . . . . . .
|
||||
. # . # . . . . . .
|
||||
. . # . . . . . . .
|
||||
# . . . # . . . . .
|
||||
. # # # . . . . . .
|
||||
`, 400)
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
||||
## 4. Now let's change the delay shown below from 400 milliseconds to 2.5 seconds.
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
. # . # . . . . . .
|
||||
. # . # . . . . . .
|
||||
. . # . . . . . . .
|
||||
# . . . # . . . . .
|
||||
. # # # . . . . . .
|
||||
`, 400)
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
Reference in New Issue
Block a user