Migrate docs from the other repo

This commit is contained in:
Michal Moskal
2016-03-25 16:47:20 -07:00
parent 38d2cf06d2
commit a08eb53f92
895 changed files with 36888 additions and 0 deletions

View File

@ -0,0 +1,44 @@
# love meter activity
create a love meter with the BBC micro:bit #docs
### ~avatar avatar
### @video td/videos/love-meter-0
Welcome! This tutorial will help you create a love meter with the BBC micro:bit. 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**.
Begin by registering an event with `input->on pin pressed(PO)` to know when someone is holding pin ``P0`` and pin ``Gnd``.
```
input.onPinPressed("P0", () => {
})
```
We are going to create a meter that displays a random number from 0 to 10. We use ``11`` as `math->random(n)` returns a number between ``0`` and ``n-1``.
```
input.onPinPressed("P0", () => {
let x = Math.random(11)
})
```
Finally, let's show that number on the micro:bit.
```
input.onPinPressed("P0", () => {
let x_ = Math.random(11)
basic.showNumber(x_, 150)
})
```
### ~avatar avatar
Excellent, you're ready to continue with the [challenges](/microbit/lessons/love-meter/challenges)!
### ~

View File

@ -0,0 +1,72 @@
# love meter challenges
create a love meter with the BBC micro:bit #docs
## Before we get started
Complete the following guided tutorial:
* [tutorial](/microbit/lessons/love-meter/tutorial)
At the end of the tutorial, click `keep editing`. Your code should look like this:
```
input.onPinPressed("P0", () => {
let x = Math.random(11)
basic.showNumber(x, 150)
})
```
### Challenge 1
Add a pause of 3000 milliseconds (3 seconds) after showing the number so that the number won't immediately disappear in the next challenge.
```
input.onPinPressed("P0", () => {
let x1 = Math.random(11)
basic.showNumber(x1, 150)
basic.pause(3000) // ***
})
```
### Challenge 2
If the rating **x** is between ``0`` and ``3`` (strictly less than ``4``), display the text "HORRIBLE!".
```
input.onPinPressed("P0", () => {
let x2 = Math.random(11)
basic.showNumber(x2, 150)
basic.pause(3000)
if (x2 < 4) {
basic.showString("HORRIBLE!", 150) // ***
}
})
```
### Challenge 3
### @video td/videos/love-meter-3
If the rating is between 4 and 7, display the text "MEDIOCRE!" **else** display the text "MATCHED!"
```
input.onPinPressed("P0", () => {
let x3 = Math.random(11)
basic.showNumber(x3, 150)
basic.pause(3000)
if (x3 < 4) {
basic.showString("HORRIBLE!", 150) // ***
} else if (x3 < 8) {
basic.showString("MEDIOCRE!", 150) // ***
}
else {
basic.showString("MATCHED!", 150) // ***
}
})
```
### Challenge 4
Use `basic->plot image` or `basic->show animation` to display images and animations instead of text for each case.

View File

@ -0,0 +1,45 @@
# love meter quiz answers
The answers to the love meter quiz. #LED #screen #variables #docs
This is the answer key for the [love meter quiz](/microbit/lessons/love-meter/quiz).
## 1. What does on pin pressed ("P0") do?
<br/>
It's a method that runs code when the user holds the GND pin with a finger of one hand and presses pin P0, completing a circuit.
## 2. Create a condition for on pin pressed ("P1").
```
input.onPinPressed("P1", () => {
})
```
## 3. What does this line of code generate?
```
let x = Math.random(10)
```
<br/>
It generates a random number between 0 and 9 then stores that number in a variable.
## 4. Why do you have to add 1 to variable x?
```
x = x + 1
```
<br/>
You have to add 1 if you want to generate a random number between 1 and 10 .
## 5. Why do you have to hold ground (GND) to make this work on the BBC micro:bit?
<br/>
You have told GND to complete the circuit.

View File

@ -0,0 +1,41 @@
# love meter quiz
Learn how to make a love meter that you can try with someone. #LED #screen #variables #docs
## Name
## Directions
Use this activity document to guide your work in the [love meter tutorial](/microbit/lessons/love-meter/tutorial).
Answer the questions below while completing the tutorial. Pay attention to the dialogues!
## 1. Describe what "input -> on pin pressed (P0)" does?
<br/>
## 2. Create a condition for on pin pressed ("P1").
<br/>
## 3. Describe what this line of code does?
```
let x = Math.random(10)
```
<br/>
## 4. Describe what adding 1 to variable x does?
```
let x_ = Math.random(10)
x = x + 1
```
<br/>
## 5. Describe why you must hold ground (GND) before pressing (P0) to run a program using "input -> on pin pressed (P0)" on the BBC micro:bit
<br/>