Migrate docs from the other repo
This commit is contained in:
76
docs/reference/js/lessons/strobe-light/challenges.md
Normal file
76
docs/reference/js/lessons/strobe-light/challenges.md
Normal file
@ -0,0 +1,76 @@
|
||||
# strobe light challenges
|
||||
|
||||
Coding challenges for the strobe light tutorial. #docs
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following guided tutorial:
|
||||
|
||||
* [tutorial](/microbit/lessons/strobe-light/tutorial)
|
||||
|
||||
At the end of the tutorial, click `keep editing`. Your code should look like this:
|
||||
|
||||
```
|
||||
for (let i = 0; i < 5; i++) {
|
||||
for (let j = 0; j < 5; j++) {
|
||||
led.plot(i, j)
|
||||
basic.pause(200)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
### @video td/videos/strobe-light-1
|
||||
|
||||
Make the LEDs light up faster by changing the **pause** from 200 to 100 milliseconds:
|
||||
|
||||
```
|
||||
for (let i1 = 0; i1 < 5; i1++) {
|
||||
for (let j1 = 0; j1 < 5; j1++) {
|
||||
led.plot(i1, j1)
|
||||
basic.pause(100) // ***
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* Run the code to see if it works as expected.
|
||||
|
||||
### Challenge 2
|
||||
|
||||
### @video td/videos/strobe-light-2
|
||||
|
||||
Make the board light up by rows instead of by columns by swapping the `i` and `j` variables in `led->plot(i, j)`.
|
||||
|
||||
```
|
||||
for (let i2 = 0; i2 < 5; i2++) {
|
||||
for (let j2 = 0; j2 < 5; j2++) {
|
||||
led.plot(j2, i2) // ***
|
||||
basic.pause(100)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* Run the code to see if it works as expected.
|
||||
|
||||
### Challenge 3
|
||||
|
||||
### @video td/videos/strobe-light-ultimate
|
||||
|
||||
Now that all the LEDs are lit up, let's make them turn off by reversing the strobe light pattern! You can use `led->unplot` to turn off a single LED.
|
||||
|
||||
```
|
||||
for (let i3 = 0; i3 < 5; i3++) {
|
||||
for (let j3 = 0; j3 < 5; j3++) {
|
||||
led.plot(j3, i3)
|
||||
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) // ***
|
||||
}
|
||||
}
|
||||
```
|
||||
|
100
docs/reference/js/lessons/strobe-light/lesson-plan.md
Normal file
100
docs/reference/js/lessons/strobe-light/lesson-plan.md
Normal file
@ -0,0 +1,100 @@
|
||||
# strobe light lesson plan
|
||||
|
||||
Learn how to create a blinking LED script. #LED #screen #plot #docs
|
||||
|
||||
## Topic
|
||||
|
||||
For loop - Blinking LED
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to control a blinking LED. We will be learning how to create a blinking app using the for loop as well as simple commands, such as plot and pause.
|
||||
|
||||
## What the teacher needs to know
|
||||
|
||||
**Program:** A stored set of instructions encoded in a language understood by the computer that does some form of computation, processing input and/or stored data to generate output.**
|
||||
|
||||
**Algorithm:** An unambiguous set of rules or a precise step-by-step guide to solve a problem or achieve a particular objective. The guided tutorial follows a algorithm and is a precise step-by-step guide to solve a problem**
|
||||
|
||||
**Loop:** A block of code repeated automatically under the program’s control. ** The blink program introduces a While Loop. While Loop is a while loop that will repeat code forever while - true.
|
||||
|
||||
**Command:** An instruction for the computer to execute, written in a particular programming language.**
|
||||
|
||||
**QuickStart Computing Glossary
|
||||
|
||||
## Documentation
|
||||
|
||||
* **plot**: [read more...](/microbit/reference/led/plot)
|
||||
* **pause**: [read more...](/microbit/reference/basic/pause)
|
||||
* **for loop**: [read more...](/microbit/reference/loops/for)
|
||||
|
||||
## Resources
|
||||
|
||||
* Activity: [tutorial](/microbit/lessons/strobe-light/tutorial)
|
||||
* Activity: [quiz](/microbit/lessons/strobe-light/quiz)
|
||||
* Extended Activity: [challenges](/microbit/lessons/strobe-light/challenges)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to blink a light
|
||||
* create a for loop that will loop through each x-value, y-value from 0 to 4.
|
||||
* learn how to pause the light on and off
|
||||
* learn how to repeat turning on and off the light
|
||||
|
||||
## Links to the National Curriculum Programmes of Study for Computing
|
||||
|
||||
## Assessment
|
||||
|
||||
**Progression Pathways:**
|
||||
|
||||
**Computational Thinking Framework:**
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* Uses logical reasoning to predict outputs, showing an awareness of inputs. (AL)
|
||||
* Understands that iteration is the repetition of a process such as a loop. (AL)
|
||||
* Represents solutions using a structured notation. (AL) (AB)
|
||||
|
||||
#### Programming & Development
|
||||
|
||||
* Creates programs that implement algorithms to achieve given goals. (AL)
|
||||
* Uses a variable and relational operators within a loop to govern termination. (AL) (GE)
|
||||
* Uses a range of operators and expressions e.g. Boolean, and applies them in the context of program control. (AL)
|
||||
|
||||
#### Data & Data Representation
|
||||
|
||||
* Understands the difference between data and information. (AB)
|
||||
* Defines data types: real numbers and Boolean. (AB)
|
||||
|
||||
#### Information Technology
|
||||
|
||||
* Collects, organises and presents data and information in digital content. (AB)
|
||||
* Makes appropriate improvements to solutions based on feedback received, and can comment on the success of the solution. (EV)
|
||||
|
||||
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation
|
||||
|
||||
## Activity
|
||||
|
||||
* time: 10 min.
|
||||
* [tutorial](/microbit/lessons/strobe-light/tutorial)
|
||||
* [quiz](/microbit/lessons/strobe-light/quiz)
|
||||
* assessment opportunities: loops, plot, pause, clear screen
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/strobe-light/challenges)
|
||||
* assessment opportunities: loops, plot, pause, clear screen
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/strobe-light/challenges)
|
||||
|
||||
## Intended follow on
|
||||
|
||||
Publish script to the classroom.
|
||||
|
70
docs/reference/js/lessons/strobe-light/quiz-answers.md
Normal file
70
docs/reference/js/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. #LED #screen #plot #docs
|
||||
|
||||
This is the answer key for the [strobe light quiz](/microbit/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
|
||||
|
||||
```
|
||||
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
|
||||
|
||||
```
|
||||
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
|
||||
|
||||
```
|
||||
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
docs/reference/js/lessons/strobe-light/quiz.md
Normal file
50
docs/reference/js/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. #LED #screen #plot #docs
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [strobe light tutorial](/microbit/lessons/strobe-light/tutorial)
|
||||
|
||||
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
|
||||
|
||||
```
|
||||
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
|
||||
|
||||
```
|
||||
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
|
||||
|
||||
```
|
||||
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