Migrate docs from the other repo
This commit is contained in:
44
docs/reference/js/lessons/zoomer/activity.md
Normal file
44
docs/reference/js/lessons/zoomer/activity.md
Normal file
@ -0,0 +1,44 @@
|
||||
# zoomer activity
|
||||
|
||||
measure the acceleration on the BBC micro:bit in the "z" direction. #microbit #docs
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
### @video td/videos/zoomer-0
|
||||
|
||||
Welcome! This tutorial will teach how to measure the acceleration on the micro:bit in the "z" direction. Let's get started!
|
||||
|
||||
### ~
|
||||
|
||||
To create a new script, go to the [Create Code](/microbit/create-code) page and tap *New Project* under **Touch Develop**.
|
||||
|
||||
We want to display the acceleration forever. In order to do so, we need a `basic->forever` loop.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
})
|
||||
```
|
||||
|
||||
Let's measure the acceleration and then store in it a variable `az`. The acceleration is measured in **milli-gravities**, so a value of `-1000` is equivalent to `-1g` or `-9.81m/s^2`.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
let az = input.acceleration("z")
|
||||
})
|
||||
```
|
||||
|
||||
Show the value of `az` on the screen.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
let az_ = input.acceleration("z")
|
||||
basic.showNumber(az_, 150)
|
||||
})
|
||||
```
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/microbit/lessons/zoomer/challenges)!
|
||||
|
||||
### ~
|
||||
|
39
docs/reference/js/lessons/zoomer/challenges.md
Normal file
39
docs/reference/js/lessons/zoomer/challenges.md
Normal file
@ -0,0 +1,39 @@
|
||||
# zoomer challenges
|
||||
|
||||
Coding challenges for the zoomer tutorial.#acceleration #docs #input
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following [guided tutorial](/microbit/lessons/zoomer/tutorial) and your finished code should look like this:
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
let az = input.acceleration("z")
|
||||
basic.showNumber(az, 150)
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
### @video td/videos/zoomer-2
|
||||
|
||||
We'll modify the code to display the `x` acceleration if the `A` button is pressed. For that, we need to store `input->acceleration(x)` in a new variable `ax` and use a `input->button is pressed(A)` to detect if the button is pressed.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
let az1 = input.acceleration("z")
|
||||
let ax = input.acceleration("x")
|
||||
if (input.buttonIsPressed("A")) {
|
||||
basic.showNumber(ax, 150) // ***
|
||||
} else {
|
||||
basic.showNumber(az1, 150) // ***
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
* Run the code to see if it works as expected.
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Display the `y` acceleration when `B` is pressed by adding another `if` statement using `input->button is pressed(B)`.
|
||||
|
35
docs/reference/js/lessons/zoomer/quiz-answers.md
Normal file
35
docs/reference/js/lessons/zoomer/quiz-answers.md
Normal file
@ -0,0 +1,35 @@
|
||||
# zoomer quiz answers
|
||||
|
||||
Measure the acceleration on the micro:bit in the "z" direction #LED #number #math #acceleration #docs
|
||||
|
||||
This is the answer key for the [zoomer quiz](/microbit/lessons/zoomer/quiz).
|
||||
|
||||
## 1. What is 'acceleration'?
|
||||
|
||||
Acceleration is amount of force being applied to the BBC micro:bit in one of three specified directions.
|
||||
|
||||
## 2. Consider the following directions
|
||||
|
||||
Write the line of code to measure the acceleration and then store in it a variable.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
let accX_ = input.acceleration("x")
|
||||
```
|
||||
|
||||
Note: acceleration does not have be measured in the "x" direction. It can also be in the "y" or "z" direction.
|
||||
|
||||
## 3. Consider the following directions
|
||||
|
||||
After storing the acceleration in a variable, write the code to show acceleration on the BBC micro:bit as a number
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
let accX = input.acceleration("x")
|
||||
basic.showNumber(accX_, 150)
|
||||
```
|
||||
|
||||
Note: make sure the same variable name ("acc x" in this case) is the same in both lines of code..
|
||||
|
24
docs/reference/js/lessons/zoomer/quiz.md
Normal file
24
docs/reference/js/lessons/zoomer/quiz.md
Normal file
@ -0,0 +1,24 @@
|
||||
# zoomer quiz
|
||||
|
||||
Measure the acceleration on the micro:bit in the "z" direction #LED #number #math #acceleration #docs
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [zoomer tutorial](/microbit/lessons/zoomer/tutorial)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. What is 'acceleration'?
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Write the line of code to measure the acceleration and then store in it a variable.
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. After storing the acceleration in a variable, write the code to show acceleration on the BBC micro:bit as a number.
|
||||
|
||||
<br/>
|
||||
|
Reference in New Issue
Block a user