move lessons out of web site

will move select lessons back to "educators" section
This commit is contained in:
Tom Ball
2016-06-14 11:49:58 -04:00
parent a6e6dd8287
commit f4eca66648
184 changed files with 8 additions and 8 deletions

View File

@ -0,0 +1,47 @@
# love meter blocks activity
Create a love meter with the micro:bit
### ~avatar avatar
Welcome! This activity will help you create a love meter with the micro:bit. Let's get started!
### ~
Begin by registering an event with `on pin pressed` *P0* to know when someone is holding pin *P0* and pin *Gnd*.
```blocks
input.onPinPressed(TouchPin.P0, () => {
})
```
We are going to create a meter that displays a random number from *0* to *10*. We use *10* as `random number up to` returns a number between *0* and *n*.
```blocks
input.onPinPressed(TouchPin.P0, () => {
let x = Math.random(10)
})
```
Finally, let's show that number on the micro:bit. You are registering an event handler that will execute on the BBC micro:bit whenever the user holds the GND pin with one hand, and presses pin 0 with the other hand, thus completing a circuit
```blocks
input.onPinPressed(TouchPin.P0, () => {
let x = Math.random(10)
basic.showNumber(x)
})
```
### ~avatar avatar
Excellent, you're ready to continue with the [challenges](/lessons/love-meter/challenges)
### ~

View File

@ -0,0 +1,69 @@
# love meter blocks challenges
Create a love meter with the micro:bit
## Before we get started
You should work on these challenges after the following the [love meter activity](/lessons/love-meter/activity)
```blocks
input.onPinPressed(TouchPin.P0, () => {
let x = Math.random(10)
basic.showNumber(x)
})
```
### 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.
```blocks
input.onPinPressed(TouchPin.P0, () => {
let x = Math.random(10)
basic.showNumber(x)
basic.pause(3000)
})
```
### Challenge 2
If the rating **x** is between *0* and *3* (strictly less than *4*), display the text "HORRIBLE!".
```blocks
input.onPinPressed(TouchPin.P0, () => {
let x = Math.random(10)
basic.showNumber(x)
basic.pause(3000)
if (x < 4) {
basic.showString("HORRIBLE")
}
})
```
### Challenge 3
**If** the rating is between 4 and 7, display the text "MEDIOCRE!" **else** display the text "MATCHED!"
```blocks
input.onPinPressed(TouchPin.P0, () => {
let x = Math.random(10)
basic.showNumber(x)
basic.pause(3000)
if (x < 4) {
basic.showString("HORRIBLE")
} else if (x < 8) {
basic.showString("MEDIOCRE")
} else {
basic.showString("MATCHED")
}
})
```
### Challenge 4
Use `show LEDs` to display images instead of text for each case.

View File

@ -0,0 +1,46 @@
# love meter blocks quiz answers
The answers to the love meter quiz.
This is the answer key for the [love meter quiz](/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. Write the code.
Create a condition for `on pin pressed (P0)`.
```blocks
input.onPinPressed(TouchPin.P0, () => {
})
```
## 3. What does this line of code doing?
```blocks
let x = Math.random(9)
```
It stores random number between 0 and 9 then stores that number in a variable.
## 4. Why do you have to add 1 to variable x?
```blocks
let item = 0;
item = 0;
basic.showNumber(item + 1);
```
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 micro:bit?
You have told GND to complete the circuit.

View File

@ -0,0 +1,39 @@
# love meter blocks quiz
Learn how to make a love meter that you can try with someone.
## Name
## Directions
Use this activity document to guide your work in the [love meter activity](/lessons/love-meter/activity).
Answer the questions below while completing the activity. Pay attention to the dialogues!
## 1. Describe what `on pin pressed` does?
## 2. Create a condition for on pin pressed (P0).
## 3. Describe what this line of code does?
```blocks
let x = Math.random(9)
```
## 4. Describe what adding 1 to variable x does?
```blocks
let item = 0;
item = 0;
basic.showNumber(item + 1);
```
## 5. Describe why you must hold ground (GND) before pressing (P0) to run a program using `on pin pressed(P0)` on the micro:bit