Migrate docs from the other repo
This commit is contained in:
41
docs/reference/js/lessons/magic-logo/activity.md
Normal file
41
docs/reference/js/lessons/magic-logo/activity.md
Normal file
@ -0,0 +1,41 @@
|
||||
# magic logo activity
|
||||
|
||||
show an image that points up when the logo is up. #docs #microbit
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
### @video td/videos/magic-logo-0
|
||||
|
||||
Welcome! This tutorial will help you display an arrow pointing toward the logo! Let's get started.
|
||||
|
||||
### ~
|
||||
|
||||
Using the **accelerometer** sensor, the BBC micro:bit can detect when the **logo** is oriented **up**. We call that the **logo up** event. We will use `input->on logo up` to register an event handler that will run when the **logo up** event happens.
|
||||
|
||||
```
|
||||
input.onLogoUp(() => {
|
||||
}) // ***
|
||||
```
|
||||
|
||||
When the BBC micro:bit goes logo up, the code nested under the `basic->on logo up` function will run. Let's add a line of code to plot an image in there.
|
||||
|
||||
```
|
||||
input.onLogoUp(() => {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`, 400) // ***
|
||||
})
|
||||
```
|
||||
|
||||
Run your code and try to turn around the BBC micro:bit to see the **logo up** event in action!
|
||||
|
||||
### ~avatar boothing
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/microbit/lessons/magic-logo/challenges)!
|
||||
|
||||
### ~
|
||||
|
55
docs/reference/js/lessons/magic-logo/challenges.md
Normal file
55
docs/reference/js/lessons/magic-logo/challenges.md
Normal file
@ -0,0 +1,55 @@
|
||||
# magic logo challenges
|
||||
|
||||
Coding challenges for the magic logo tutorial. #docs
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the [magic logo](/microbit/lessons/magic-logo/activity) activity and your code will look like this:
|
||||
|
||||
```
|
||||
input.onLogoUp(() => {
|
||||
basic.plotImage(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
How about when the logo is down? We should display an arrow pointing downward!
|
||||
|
||||
### @video td/videos/magic-logo-1-2
|
||||
|
||||
```
|
||||
input.onLogoUp(() => {
|
||||
basic.plotImage(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
})
|
||||
input.onLogoDown(() => {
|
||||
basic.plotImage(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`) // ***
|
||||
}) // ***
|
||||
```
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Use the `input->on screen up` event to show a spinning arrow when the screen is turned up.
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Display another animation using the `input->on screen up` event.
|
||||
|
51
docs/reference/js/lessons/magic-logo/quiz-answers.md
Normal file
51
docs/reference/js/lessons/magic-logo/quiz-answers.md
Normal file
@ -0,0 +1,51 @@
|
||||
# magic logo quiz answers
|
||||
|
||||
show an image that points up when the logo is up #logo #show #create #docs
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
This is the answer key for the [magic logo quiz](/microbit/lessons/magic-logo/quiz)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Define 'on logo up'
|
||||
|
||||
A function that will run code when the BBC micro:bit screen is facing up and vertically orientated.
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Consider the following directions
|
||||
|
||||
Write the condition that detects when the BBC micro:bit logo is facing up and vertically orientated.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
input.onLogoUp(() => {
|
||||
})
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Consider the following animation
|
||||
|
||||

|
||||
|
||||
Write the code to display a downward pointing arrow when the logo is down.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
input.onLogoDown(() => {
|
||||
basic.plotImage(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
})
|
||||
```
|
||||
|
26
docs/reference/js/lessons/magic-logo/quiz.md
Normal file
26
docs/reference/js/lessons/magic-logo/quiz.md
Normal file
@ -0,0 +1,26 @@
|
||||
# magic logo quiz
|
||||
|
||||
show an image that points up when the logo is up #logo #show #create #docs
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use the hints from the [magic logo activity](/microbit/lessons/magic-logo/activity) to answer this quiz!
|
||||
|
||||
## 1. Define what `input->on logo up` does
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. The `logo up` event is raised when...
|
||||
|
||||
* the screen is facing up and the board is horizontal
|
||||
* the screen is facing down and the board is horizontal
|
||||
* the board is vertical and the logo is facing up
|
||||
|
||||
## 3. Consider the following animation
|
||||
|
||||

|
||||
|
||||
Write the code to display a downward pointing arrow when the BBC micro:bit logo is down.
|
||||
|
Reference in New Issue
Block a user