move lessons out of web site
will move select lessons back to "educators" section
This commit is contained in:
62
olddocs/lessons/strobe-light/activity.md
Normal file
62
olddocs/lessons/strobe-light/activity.md
Normal file
@ -0,0 +1,62 @@
|
||||
# strobe light activity
|
||||
|
||||
Develop shapes with a for loop.
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
|
||||
|
||||
Welcome! This guided tutorial will teach how to develop shapes with a for loop. Let's get started!
|
||||
|
||||
### ~
|
||||
|
||||
Create a `for loop` that will loop from 0 to 4 to indicate the x-coordinates of the micro:bit display.
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 5; i++) {
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Create another for loop that will loop from 0 to 4, indicating the y-coordinates of the micro:bit instead. This for loop will light each LED by column.
|
||||
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 5; i++) {
|
||||
for (let j = 0; j < 5; j++) {
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
We will light up each LED by plotting them individually.
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 5; i++) {
|
||||
for (let j = 0; j < 5; j++) {
|
||||
led.plot(i, j)
|
||||
basic.pause(200)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
The pause will add a delay between lighting each LED.
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 5; i++) {
|
||||
for (let j = 0; j < 5; j++) {
|
||||
led.plot(i, j)
|
||||
basic.pause(200)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/lessons/strobe-light/challenges)!
|
||||
|
||||
### ~
|
||||
|
73
olddocs/lessons/strobe-light/challenges.md
Normal file
73
olddocs/lessons/strobe-light/challenges.md
Normal file
@ -0,0 +1,73 @@
|
||||
# strobe light challenges
|
||||
|
||||
Coding challenges for strobe light.
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following [guided tutorial](/lessons/strobe-light/activity), your code should look like this:
|
||||
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 5; i++) {
|
||||
for (let j = 0; j < 5; j++) {
|
||||
led.plot(i, j)
|
||||
basic.pause(200)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Challenge 1
|
||||
|
||||
|
||||
|
||||
Make the LEDs light up faster by changing the **pause** from 200 to 100 milliseconds:
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 5; i++) {
|
||||
for (let j = 0; j < 5; j++) {
|
||||
led.plot(i, j)
|
||||
basic.pause(100)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* Run the code to see if it works as expected.
|
||||
|
||||
### Challenge 2
|
||||
|
||||
|
||||
|
||||
Make the board light up by rows instead of by columns by swapping the `i` and `j` variables in `plot(i, j)`.
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 5; i++) {
|
||||
for (let j = 0; j < 5; j++) {
|
||||
led.plot(j, i)
|
||||
basic.pause(100)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* Run the code to see if it works as expected.
|
||||
|
||||
### Challenge 3
|
||||
|
||||
|
||||
|
||||
Now that all the LEDs are lit up, let's make them turn off by reversing the strobe light pattern! You can use `unplot` to turn off a single LED.
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 5; i++) {
|
||||
for (let j = 0; j < 5; j++) {
|
||||
led.plot(j, i)
|
||||
basic.pause(100)
|
||||
}
|
||||
}
|
||||
for (let k = 0; k < 5; k++) {
|
||||
for (let l = 0; l < 5; l++) {
|
||||
led.unplot(4 - l, 4 - k)
|
||||
basic.pause(100)
|
||||
}
|
||||
}
|
||||
```
|
70
olddocs/lessons/strobe-light/quiz-answers.md
Normal file
70
olddocs/lessons/strobe-light/quiz-answers.md
Normal file
@ -0,0 +1,70 @@
|
||||
# strobe light quiz answers
|
||||
|
||||
Learn how to create a blinking images with a for loop.
|
||||
|
||||
This is the answer key for the [strobe light quiz](/lessons/strobe-light/quiz).
|
||||
|
||||
## 1. What is a for loop?
|
||||
|
||||
Answers will vary. In general, for loop refers to the code that repeats for a fixed number of times. We specify the LED using x, y coordinates.
|
||||
|
||||
## 2. Consider the following code
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 5; i++) {
|
||||
for (let j = 0; j < 5; j++) {
|
||||
led.plot(i, j)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If the rectangle below represents a board that is 5 LEDs wide and 5 LEDs tall, place an X approximately where the LED is lighted. Explain why the LED is lighted there.
|
||||
|
||||

|
||||
|
||||
This code turns on specific LED. Plot turns on the specified LED on the LED screen. We specify the LED using x, y coordinates. The code lights on the LEDs
|
||||
|
||||
``x`` - the x coordinate or horizontal position (0,1,2,3,4)
|
||||
|
||||
``y`` - the y coordinate or vertical position (0,1,2,3,4)
|
||||
|
||||
## 3. Consider the following code
|
||||
|
||||
```blocks
|
||||
for (let i1 = 0; i1 < 3; i1++) {
|
||||
for (let j1 = 0; j1 < 3; j1++) {
|
||||
led.plot(i1, j1)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If the rectangle below represents a board that is 5 LEDs wide and 5 LEDs tall, place an X approximately where the LED is lighted. Explain why the LED is lighted there.
|
||||
|
||||

|
||||
|
||||
This code turns on specific LED. Plot turns on the specified LED on the LED screen. We specify the LED using x, y coordinates.
|
||||
|
||||
``x`` - the x coordinate or horizontal position (0,1,2)
|
||||
|
||||
``y`` - the y coordinate or vertical position (0,1,2)
|
||||
|
||||
## 4. Consider the following code
|
||||
|
||||
```blocks
|
||||
for (let i2 = 0; i2 < 2; i2++) {
|
||||
for (let j2 = 0; j2 < 2; j2++) {
|
||||
led.plot(i2, j2)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If the rectangle below represents a board that is 5 LEDs wide and 5 LEDs tall, place an X approximately where the LED is lighted. Explain why the LED is lighted there.
|
||||
|
||||

|
||||
|
||||
This code turns on specific LED. Plot turns on the specified LED on the LED screen. We specify the LED using x, y coordinates.
|
||||
|
||||
``x`` - the x coordinate or horizontal position (0,1)
|
||||
|
||||
``y`` - the y coordinate or vertical position (0,1)
|
||||
|
50
olddocs/lessons/strobe-light/quiz.md
Normal file
50
olddocs/lessons/strobe-light/quiz.md
Normal file
@ -0,0 +1,50 @@
|
||||
# strobe light quiz
|
||||
|
||||
Learn how to create a blinking LED script with a for loop.
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [strobe light tutorial](/lessons/strobe-light/activity)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. What is a for loop?
|
||||
|
||||
## 2. Draw which LEDs are ON after running this code
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 5; i++) {
|
||||
for (let j = 0; j < 5; j++) {
|
||||
led.plot(i, j)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
|
||||
## 3. Draw which LEDs are ON after running this code
|
||||
|
||||
```blocks
|
||||
for (let i1 = 0; i1 < 3; i1++) {
|
||||
for (let j1 = 0; j1 < 3; j1++) {
|
||||
led.plot(i1, j1)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
|
||||
## 4. Draw which LEDs are ON after running this code
|
||||
|
||||
```blocks
|
||||
for (let i2 = 0; i2 < 2; i2++) {
|
||||
for (let j2 = 0; j2 < 2; j2++) {
|
||||
led.plot(i2, j2)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
|
Reference in New Issue
Block a user