put lessons back for Michael
This commit is contained in:
40
docs/lessons/temperature/activity.md
Normal file
40
docs/lessons/temperature/activity.md
Normal file
@ -0,0 +1,40 @@
|
||||
# temperature activity
|
||||
|
||||
Measure the temperature on the micro:bit
|
||||
|
||||
Welcome! This activity will teach how to measure the temperature on the micro:bit. Let's get started!
|
||||
|
||||
We want to display the temperature on shake. In order to do so, we need to register the event `on shake` that will execute whenever the user shakes the micro:bit; in the web browser, click the button labelled "SHAKE" under the simulator to generate a shake event
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
|
||||
})
|
||||
```
|
||||
|
||||
Let's measure the temperature and then store in it a variable `temp`. The temperature is measured in **Celsius**, so a value of `29` is equivalent to 29 degrees Celsius.
|
||||
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let temp = input.temperature()
|
||||
})
|
||||
```
|
||||
|
||||
Show the value of `temp` on the screen.
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let temp = input.temperature()
|
||||
basic.showNumber(temp)
|
||||
})
|
||||
```
|
||||
|
||||
* click run to see if the code works as expected.
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/lessons/temperature/challenges)!
|
||||
|
||||
### ~
|
||||
|
33
docs/lessons/temperature/challenges.md
Normal file
33
docs/lessons/temperature/challenges.md
Normal file
@ -0,0 +1,33 @@
|
||||
# temperature challenges
|
||||
|
||||
Coding challenges for zoomer.
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following guided [temperature activity](/lessons/temperature/activity). At the end of the activity, your code should look like this:
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let temp = input.temperature()
|
||||
basic.showNumber(temp)
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Let's add the code to display the text `C IS THE TEMP` with a `show string` block. Modify the `show string` block to slowly display the text by an interval of `300`.
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let temp = input.temperature()
|
||||
basic.showNumber(temp)
|
||||
basic.showString("C IS THE TEMP")
|
||||
})
|
||||
```
|
||||
|
||||
* Run the code to see if it works as expected.
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Let's add code to display the temperature gauge image with a `show LEDs` block.
|
||||
|
Reference in New Issue
Block a user