move lessons out of web site
will move select lessons back to "educators" section
This commit is contained in:
71
olddocs/lessons/flashing-heart/activity.md
Normal file
71
olddocs/lessons/flashing-heart/activity.md
Normal file
@ -0,0 +1,71 @@
|
||||
# flashing heart blocks activity
|
||||
|
||||
Control images with a variable.
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
In this activity, you will learn how to blink an image on the LED screen.
|
||||
|
||||
### ~
|
||||
|
||||
Let's start by adding code that plots a heart image on the screen using `show LEDs`. Once you are done coding, don't forget to run your code in the simulator or the micro:bit.
|
||||
|
||||
|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .`);
|
||||
```
|
||||
|
||||
We want to leave the image on the screen for 0.5 seconds (500 milliseconds), then clear the screen. We can use `pause` to wait and `clear screen` to turn off the LEDs.
|
||||
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
basic.pause(500)
|
||||
basic.clearScreen()
|
||||
})
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
Finally, we can surround this code with a `forever` loop to repeat it and add a pause after `clear screen` to keep the screen off for a little while. Modify your code so that your code looks like this.
|
||||
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
basic.pause(500)
|
||||
basic.clearScreen()
|
||||
basic.pause(500)
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
### ~avatar boothing
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/lessons/flashing-heart/challenges)!
|
||||
|
||||
### ~
|
||||
|
96
olddocs/lessons/flashing-heart/challenges.md
Normal file
96
olddocs/lessons/flashing-heart/challenges.md
Normal file
@ -0,0 +1,96 @@
|
||||
# flashing heart blocks challenges
|
||||
|
||||
Coding challenges for the flashing heart tutorial.
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the [flashing heart](/lessons/flashing-heart/activity) activity and your code will look like this:
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
basic.pause(500)
|
||||
basic.clearScreen()
|
||||
basic.pause(500)
|
||||
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Let's plot a different image. Let's display a broken heart!
|
||||
|
||||
To do this, you need to add a block between the last line and the end loop. Add a `show LEDs` block and then add a `pause` of 500 milliseconds.
|
||||
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
basic.pause(500)
|
||||
basic.clearScreen()
|
||||
basic.pause(500)
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# . # # #
|
||||
# . . # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
basic.pause(500)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
* click *run main* to see if the code works as expected.
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Now let's alternate flashing the heart and the broken heart. To do this, we need to add a `clear screen` block and then add a `pause` block of 500 milliseconds under the new code we added in Challenge 1.
|
||||
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# . # # #
|
||||
# . . # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
basic.pause(500)
|
||||
basic.clearScreen()
|
||||
basic.pause(500)
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# . # # #
|
||||
# . . # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
basic.pause(500)
|
||||
basic.clearScreen()
|
||||
basic.pause(500)
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
|
||||
* click *run main* to see if the code works as expected.
|
||||
|
||||
### Challenge 3
|
||||
|
||||
You now have a heart and broken heart flashing! Now plot a new image to alternate in with the heart and broken heart.
|
||||
|
24
olddocs/lessons/flashing-heart/quiz-answers.md
Normal file
24
olddocs/lessons/flashing-heart/quiz-answers.md
Normal file
@ -0,0 +1,24 @@
|
||||
# flashing heart blocks quiz answers
|
||||
|
||||
Learn how to create an image with a variable.
|
||||
|
||||
This is the answer key for the [flashing heart quiz](/lessons/flashing-heart/quiz).
|
||||
|
||||
## 1. Describe what pause does
|
||||
|
||||
Pause program execution for the specified number of milliseconds.
|
||||
|
||||
## 2. Write the code that leaves an image on the screen for 1 second (1000 milliseconds)
|
||||
|
||||
|
||||
```blocks
|
||||
basic.pause(1000)
|
||||
```
|
||||
|
||||
## 3. Write the code that leaves an image on the screen for 1.5 seconds (1500 milliseconds)
|
||||
|
||||
```blocks
|
||||
basic.pause(1500)
|
||||
```
|
||||
|
||||
|
25
olddocs/lessons/flashing-heart/quiz.md
Normal file
25
olddocs/lessons/flashing-heart/quiz.md
Normal file
@ -0,0 +1,25 @@
|
||||
# flashing heart blocks quiz
|
||||
|
||||
Learn how to create a blinking image with a variable.
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [flashing heart activity](/lessons/flashing-heart/activity).
|
||||
|
||||
Answer the questions while completing the activity. Pay attention to the dialogues!
|
||||
|
||||
## 1. Describe what `pause` does?
|
||||
|
||||
|
||||
|
||||
## 2. Write the code that leaves an image on the screen for 1 second (1000 milliseconds)
|
||||
|
||||
|
||||
|
||||
|
||||
## 3. Write the code that leaves an image on the screen for 1.5 seconds (1500 milliseconds)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user