Migrate docs from the other repo
This commit is contained in:
43
docs/lessons/magic-logo/activity.md
Normal file
43
docs/lessons/magic-logo/activity.md
Normal file
@ -0,0 +1,43 @@
|
||||
# magic logo activity
|
||||
|
||||
Show an image that points up when the logo is up.
|
||||
|
||||
### ~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 micro:bit can detect when the **logo** is oriented **up**. We call that the **logo up** event. We will use `on logo up` to register an event handler that will run when the **logo up** event happens.
|
||||
|
||||
```blocks
|
||||
input.onLogoUp(() => {
|
||||
|
||||
})
|
||||
```
|
||||
|
||||
When the micro:bit goes logo up, the code nested under the `on logo up` function will run. Let's add a line of code to show LEDs in there.
|
||||
|
||||
```blocks
|
||||
input.onLogoUp(() => {
|
||||
basic.showAnimation(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
Run your code and try to turn around the 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)!
|
||||
|
||||
### ~
|
||||
|
60
docs/lessons/magic-logo/challenges.md
Normal file
60
docs/lessons/magic-logo/challenges.md
Normal file
@ -0,0 +1,60 @@
|
||||
# magic logo challenges
|
||||
|
||||
Coding challenges for magic logo.
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the [magic logo](/microbit/lessons/magic-logo/activity) activity and your code will look like this:
|
||||
|
||||
```blocks
|
||||
input.onLogoUp(() => {
|
||||
basic.showAnimation(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Challenge 1
|
||||
|
||||
How about when the logo is down? We should display an arrow pointing downward!
|
||||
|
||||
### @video td/videos/magic-logo-1-2
|
||||
|
||||
```blocks
|
||||
input.onLogoUp(() => {
|
||||
basic.showAnimation(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
})
|
||||
input.onLogoDown(() => {
|
||||
basic.showAnimation(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
})
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Use the `on screen up` event to show a spinning arrow when the screen is turned up.
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Display another animation using the `on screen up` event.
|
||||
|
Reference in New Issue
Block a user