Migrate docs from the other repo
This commit is contained in:
103
docs/reference/js/lessons/2-player-pong.md
Normal file
103
docs/reference/js/lessons/2-player-pong.md
Normal file
@ -0,0 +1,103 @@
|
||||
# 2 player pong lesson
|
||||
|
||||
make a game to test your focus on the moving ball #function #on-button-pressed #if #show-animation #mod #random #Boolean #docs
|
||||
|
||||
## Topic
|
||||
|
||||
Functions
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [tutorial](/microbit/lessons/2-player-pong/tutorial)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to create **functions**, `function()` as a unit of code that performs a specific task and returns a result. We will be learning how to create the hat game app using functions, global variables, input on button pressed, if (conditionals), mod, random, Boolean, as well as simple commands such as show animation.
|
||||
|
||||
## What the teacher needs to know/QuickStart Computing Glossary
|
||||
|
||||
* Algorithm: An unambiguous set of rules or a precise step-bystep guide to solve a problem or achieve a particular objective.
|
||||
* Command: An instruction for the computer to execute, written in a particular programming language.
|
||||
* Data: A structured set of numbers, possibly representing digitised text, images, sound or video, which can be processed or transmitted by a computer, also used for numerical (quantitative) information.
|
||||
* Hardware: The physical systems and components of digital devices; see also software.
|
||||
* Input: Data provided to a computer system, such as via a keyboard, mouse, microphone, camera or physical sensors.
|
||||
* Programmable toys: Robots designed for children to use, accepting input, storing short sequences of simple instructions and moving according to this stored program.
|
||||
* 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.
|
||||
* Repetition: Executing a section of computer code a number of times as part of the program.
|
||||
* Script: A computer program typically executed one line at a time through an interpreter, such as the instructions for a Scratch character.
|
||||
* Selection: A programming construct in which one section of code or another is executed depending on whether a particular condition is met.
|
||||
* Sequence: To place program instructions in order, with each executed one after the other.
|
||||
* Simulation: Using a computer to model the state and behaviour of real-world (or imaginary) systems, including physical or social systems; an integral part of most computer games.
|
||||
* Variables: A way in which computer programs can store, retrieve or change data, such as a score, the time left, or the user’s name.
|
||||
|
||||
## Documentation
|
||||
|
||||
* **functions** : [read more...](/microbit/js/function)
|
||||
* **on button pressed** : [read more...](/microbit/reference/input/on-button-pressed)
|
||||
* **for** : [read more...](/microbit/reference/loops/for)
|
||||
* **if** : [read more...](/microbit/reference/logic/if)
|
||||
* **show animation** : [read more...](/microbit/reference/basic/show-animation)
|
||||
|
||||
## Resources
|
||||
|
||||
* Activity: [tutorial](/microbit/lessons/2-player-pong/tutorial)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to create a global variable as a place where you can store data so that you can use it later in your code, accessible across functions and in nested code blocks
|
||||
* learn how to learn how to conditionally run code depending on whether a condition is true or no
|
||||
* learn how to show a series of image frames on the LED screen
|
||||
* learn how to run code when an input button is pressed
|
||||
|
||||
## Links to the National Curriculum Programmes of Study for Computing
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* Designs solutions (algorithms) that use repetition and two-way selection, ie if, then and else.(AL)
|
||||
* Uses diagrams to express solutions.(AB)
|
||||
* Uses logical reasoning to predict outputs, showing an awareness of inputs (AL)
|
||||
* Represents solutions using a structured notation (AL) (AB)
|
||||
|
||||
#### Programming & Development
|
||||
|
||||
* Creates programs that implement algorithms to achieve given goals (AL)
|
||||
* Declares and assigns variables(AB)
|
||||
* Uses post-tested loop e.g.‘until’,and a sequence of selection statements in programs,including an if,then and else statement(AL)
|
||||
* Understands the difference between, and appropriately uses if and if, then and else statements(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)
|
||||
* Selects the appropriate data types(AL) (AB
|
||||
|
||||
#### Data & Data Representation
|
||||
|
||||
* Understands the difference between data and information(AB)
|
||||
* Performs more complex searches for information e.g. using Boolean and relational operators(AL) (GE) (EV)
|
||||
* Defines data types: real numbers and Boolean (AB)
|
||||
|
||||
#### Hardware & Processing
|
||||
|
||||
* Knows that computers collect data from various input devices, including sensors and application software (AB)
|
||||
|
||||
#### Information Technology
|
||||
|
||||
* Collects, organizes, 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)
|
||||
* Recognises ethical issues surrounding the application of information technology beyond school.
|
||||
|
||||
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation
|
||||
|
||||
## Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [tutorial](/microbit/lessons/2-player-pong/tutorial)
|
||||
|
||||
## Intended follow on
|
||||
|
||||
Publish script to the classroom.
|
||||
|
91
docs/reference/js/lessons/2-player-pong/quiz-answers.md
Normal file
91
docs/reference/js/lessons/2-player-pong/quiz-answers.md
Normal file
@ -0,0 +1,91 @@
|
||||
# 2 player pong quiz answers
|
||||
|
||||
a two-player game of Pong using TWO BBC micro:bits! #LED #number #math #acceleration #docs
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [2 player pong tutorial](/microbit/lessons/2-player-pong/tutorial)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Write the two global variables that record if the player has the ball and if the game is running, and assign these variables to their initial values.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
hasBall = false
|
||||
gameRunning = false
|
||||
```
|
||||
|
||||
## 2. Write the global variable that keeps track of the game state in which whoever presses button A first will get to start the ball. Assign this variable to its initial value.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
claimBall = true
|
||||
```
|
||||
|
||||
## 3. Write the code that creates a condition to know when Button A is pressed. Then write the 'If statement' to ensure that 'claim ball' is true. If the claim ball is true, then write the code that sets P0 to 1 to signal to the other device that the player has claimed the ball.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
input.onButtonPressed("A", () => {
|
||||
if (claimBall) {
|
||||
pins.digitalWritePin("P0", 1)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## 4. Write the code to move the paddle right when button B is pressed. Be sure to check if the game is running and if the paddle is not already on the rightmost edge.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
if (gameRunning) {
|
||||
if (paddleX != 0) {
|
||||
led.unplot(paddleX, 4)
|
||||
paddleX = paddleX - 1
|
||||
led.plot(paddleX, 4)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 5. What are the three pieces of information that we send to the other device when transferring the ball? (Hint: look in your "transfer ball" function, and look for any places that contain "transfer byte").
|
||||
|
||||
<br/>
|
||||
|
||||
The device first transfers a bit of 1 to indicate that the device is going to transfer the data of the ball. After that, the device transfers the x-coordinate of the ball, and then the x-velocity of the ball.
|
||||
|
||||
## 6. Using the function "read velocity", write the code that reads the x-coordinate and the x-velocity of the ball. (Hint: look at the function "read ball".)
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
ballX = micro_bitTransfer.readByte()
|
||||
ballXVelocity = readVelocity()
|
||||
```
|
||||
|
||||
## 7. Write the code that updates 'ball x velocity'. (Hint: look at the "update velocity" function.)
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
if (ballX == 0 || ballX == 4) {
|
||||
ballXVelocity = ballXVelocity * (-1)
|
||||
}
|
||||
```
|
||||
|
||||
## 8. Write the code to move the ball. To move the ball, unplot the ball's original position, update its position variables, and then plot the ball's new position.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
led.unplot(ballX, 0)
|
||||
ballX = ballX + ballXVelocity
|
||||
ballY = ballY + ballYVelocity
|
||||
led.plot(ballX, ballY)
|
||||
```
|
||||
|
70
docs/reference/js/lessons/2-player-pong/quiz.md
Normal file
70
docs/reference/js/lessons/2-player-pong/quiz.md
Normal file
@ -0,0 +1,70 @@
|
||||
# 2 player pong quiz
|
||||
|
||||
a two-player game of Pong using TWO BBC micro:bits! #LED #number #math #acceleration #docs
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [2 player pong tutorial](/microbit/lessons/2-player-pong/tutorial)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Write the two global variables that record if the player has the ball and if the game is running, and assign these variables to their initial values.
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Write the global variable that keeps track of the game state in which whoever presses button A first will get to start the ball. Assign this variable to its initial value.
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Write the code that creates a condition to know when Button A is pressed. Then write the 'If statement' to ensure that 'claim ball' is true. If the 'claim ball' is true, then write the code that sets P0 to 1 to signal to the other device that the player has claimed the ball.
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 4. Write the code to move the paddle right when button B is pressed. Be sure to check if the game is running and if the paddle is not already on the rightmost edge.
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 5. What are the three pieces of information that we send to the other device when transferring the ball? (Hint: look in your "transfer ball" function, and look for any places that contain "transfer byte").
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 6. Using the function "read velocity", write the code that reads the x-coordinate and the x-velocity of the ball. (Hint: look at the function "read ball".)
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 7. Write the code that updates 'ball x velocity'. (Hint: look at the "update velocity" function.)
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 8. Write the code to move the ball. To move the ball, unplot the ball's original position, update its position variables, and then plot the ball's new position.
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
59
docs/reference/js/lessons/accelerometer/challenges.md
Normal file
59
docs/reference/js/lessons/accelerometer/challenges.md
Normal file
@ -0,0 +1,59 @@
|
||||
# zoomer challenges
|
||||
|
||||
The acceleration function. #acceleration #docs #input
|
||||
|
||||
**Challenge 0**
|
||||
|
||||
Great job! You have successfully completed the [zoomer tutorial](https://test.microbit.co.uk/td/lessons/zoomer/challenges) . You have created a script that measures the acceleration on the micro:bit in the "z" direction of a 3D world.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
let millig = input.acceleration("z")
|
||||
basic.showNumber(millig, 150)
|
||||
basic.pause(100)
|
||||
})
|
||||
```
|
||||
|
||||
**Challenge 1**
|
||||
|
||||
Create a new variable called milliX that holds the acceleration in the "x" direction or the horizontal direction.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
let millig1 = input.acceleration("z")
|
||||
basic.showNumber(millig1, 150)
|
||||
basic.pause(100)
|
||||
let milliX = input.acceleration("x") // ***
|
||||
})
|
||||
```
|
||||
|
||||
* Run the code to see if it works as expected.
|
||||
|
||||
**Challenge 2**
|
||||
|
||||
If Button `A` is pressed, we want to show the acceleration in the "x" direction by adding an if statement that checks to see if Button `A` is pressed and then calling the show number method passing in milliX as the number.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
let millig2 = input.acceleration("z")
|
||||
basic.showNumber(millig2, 150)
|
||||
basic.pause(100)
|
||||
let milliX1 = input.acceleration("x")
|
||||
if (input.buttonIsPressed("A")) {
|
||||
basic.showNumber(milliX1, 150) // ***
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
* Run the code to see if it works as expected.
|
||||
|
||||
### Challenge 3
|
||||
|
||||
If Button `B` is pressed, program the micro:bit to display the acceleration in the "y" direction.
|
||||
|
||||
You can do this by storing the acceleration in a variable: `var milliY := input->acceleration("y")`.
|
||||
|
||||
Then add an `if` statement that checks if Button `B` is pressed: `if input-> button is pressed ("B") then`.
|
||||
|
||||
Inside of the `if` statement, add `basic->show number(milliY, 150)`, which will display the acceleration in the "y" direction.
|
||||
|
81
docs/reference/js/lessons/answering-machine.md
Normal file
81
docs/reference/js/lessons/answering-machine.md
Normal file
@ -0,0 +1,81 @@
|
||||
# answering machine lesson
|
||||
|
||||
create an answering machine on the BBC micro:bit #docs
|
||||
|
||||
### @video td/videos/answering-machine-0
|
||||
|
||||
## Topic
|
||||
|
||||
Show String
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [activity](/microbit/lessons/answering-machine/activity)
|
||||
* [quiz](/microbit/lessons/answering-machine/quiz)
|
||||
* [quiz answers](/microbit/lessons/answering-machine/quiz-answers)
|
||||
* [challenges](/microbit/lessons/answering-machine/challenges)
|
||||
* [tutorial](/microbit/lessons/answering-machine/tutorial)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning / place of lesson in scheme of work
|
||||
|
||||
Learn how to creating a message with a **string**, `basic->show string` to write your message. We will be learning how to create a message using simple commands, such as show string and on button pressed.
|
||||
|
||||
## Documentation
|
||||
|
||||
* **show string** : [read more...](/microbit/reference/basic/show-string)
|
||||
* **on button pressed** : [read more...](/microbit/reference/input/on-button-pressed)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to show a string on the LED screen one character at a time
|
||||
* learn how to use to register an event handler that will execute whenever an input button is pressed
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* Uses diagrams to express solutions.(AB)
|
||||
* Uses logical reasoning to predict outputs, showing an awareness of inputs (AL)
|
||||
* Represents solutions using a structured notation (AL) (AB)
|
||||
|
||||
#### Programming & Development
|
||||
|
||||
* Creates programs that implement algorithms to achieve given goals (AL)
|
||||
|
||||
#### Hardware & Processing
|
||||
|
||||
* Knows that computers collect data from various input devices, including sensors and application software (AB)
|
||||
|
||||
#### Communication Networks
|
||||
|
||||
* Demonstrates responsible use of technologies and online services, and knows a range of ways to report concerns (AL)
|
||||
|
||||
#### Information Technology
|
||||
|
||||
* Collects, organizes, 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)
|
||||
* Uses criteria to evaluate the quality of solutions, can identify improvements making some refinements to the solution, and future solutions (EV)
|
||||
* Evaluates the appropriatness of digital devices, internet services and application software to achieve given goals (EV)
|
||||
* Recognises ethical issues surrounding the application of information technology beyond school.
|
||||
|
||||
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation
|
||||
|
||||
## Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [activity](/microbit/lessons/answering-machine/activity)
|
||||
* [quiz](/microbit/lessons/answering-machine/quiz)
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/answering-machine/challenges)
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/answering-machine/challenges)
|
||||
|
25
docs/reference/js/lessons/banana-keyboard.md
Normal file
25
docs/reference/js/lessons/banana-keyboard.md
Normal file
@ -0,0 +1,25 @@
|
||||
# banana keyboard blocks lesson
|
||||
|
||||
display beautiful images on the BBC micro:bit #var #pause #docs
|
||||
|
||||
## Topic
|
||||
|
||||
Music
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [activity](/microbit/lessons/banana-keyboard/activity)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to convert your BBC micro:bit into a music player using pins P0 and GND, earphones (or speakers), as well as crocodile clips (or spring clips). The connect fruit using pins P1 and GND.
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to setup the BBC micro:bit with earphones to play music
|
||||
* learn how to setup the BBC micro:bit with fruit be the musical instrument
|
||||
|
76
docs/reference/js/lessons/beautiful-image.md
Normal file
76
docs/reference/js/lessons/beautiful-image.md
Normal file
@ -0,0 +1,76 @@
|
||||
# beautiful image lesson
|
||||
|
||||
display beautiful images on the BBC micro:bit #var #pause #docs
|
||||
|
||||
### @video td/videos/beautiful-image-0
|
||||
|
||||
## Topic
|
||||
|
||||
Show LEDs
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [activity](/microbit/lessons/beautiful-image/activity)
|
||||
* [quiz](/microbit/lessons/beautiful-image/quiz)
|
||||
* [quiz answers](/microbit/lessons/beautiful-image/quiz-answers)
|
||||
* [challenges](/microbit/lessons/beautiful-image/challenges)
|
||||
* [tutorial](/microbit/lessons/beautiful-image/tutorial)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to **show LEDs**, to show an image on the BBC micro:bit's LED screen. We will be learning how to Show LEDs using simple commands such as Show LEDs and pause.
|
||||
|
||||
## Documentation
|
||||
|
||||
* **show LEDs** : [read more...](/microbit/reference/basic/show-leds)
|
||||
* **pause** : [read more...](/microbit/reference/basic/pause)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to display an image on the micro:bit's LED screen
|
||||
* learn how to pause your code for the specified number of milliseconds
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* Uses diagrams to express solutions.(AB)
|
||||
* Represents solutions using a structured notation (AL) (AB)
|
||||
* Can identify similarities and differences in situations and can use these to solve problems (pattern recognition)(GE)
|
||||
|
||||
#### Programming & Development
|
||||
|
||||
* Creates programs that implement algorithms to achieve given goals (AL)
|
||||
* Declares and assigns variables(AB)
|
||||
* Selects the appropriate data types(AL) (AB
|
||||
|
||||
#### Communication Networks
|
||||
|
||||
* Demonstrates responsible use of technologies and online services, and knows a range of ways to report concerns Understands how search engines rank search results (AL)
|
||||
|
||||
#### Information Technology
|
||||
|
||||
* Collects, organizes, 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: 20 min.
|
||||
* [tutorial](/microbit/lessons/beautiful-image/tutorial)
|
||||
* [quiz](/microbit/lessons/beautiful-image/quiz)
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/beautiful-image/challenges)
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/beautiful-image/challenges)
|
||||
|
97
docs/reference/js/lessons/blink.md
Normal file
97
docs/reference/js/lessons/blink.md
Normal file
@ -0,0 +1,97 @@
|
||||
# blink lesson
|
||||
|
||||
Learn how to create a blinking LED. #LED #screen #plot #docs #lesson
|
||||
|
||||
### @video td/videos/blink-0
|
||||
|
||||
## Topic
|
||||
|
||||
Plot
|
||||
|
||||
## Quick links
|
||||
|
||||
* [activity](/microbit/lessons/blink/activity)
|
||||
* [quiz](/microbit/lessons/blink/quiz)
|
||||
* [quiz answers](/microbit/lessons/blink/quiz-answers)
|
||||
* [challenges](/microbit/lessons/blink/challenges)
|
||||
* [tutorial](/microbit/lessons/blink/tutorial)
|
||||
|
||||
## 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 forever as well as simple commands, such as plot, unplot and pause.
|
||||
|
||||
## What the teacher needs to know / QuickStart Computing Glossary
|
||||
|
||||
**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 Forever. The forever loop repeats code in the background forever.
|
||||
|
||||
**Command:** An instruction for the computer to execute, written in a particular programming language.
|
||||
|
||||
## Documentation
|
||||
|
||||
* **plot**: [read more...](/microbit/reference/led/plot)
|
||||
* **unplot**: [read more...](/microbit/reference/led/unplot)
|
||||
* **pause**: [read more...](/microbit/reference/basic/pause)
|
||||
* **forever**: [read more...](/microbit/reference/basic/forever)
|
||||
|
||||
## Resources
|
||||
|
||||
* Activity: [tutorial](/microbit/lessons/blink/tutorial)
|
||||
* Activity: [quiz](/microbit/lessons/blink/quiz)
|
||||
* Extended Activity: [challenges](/microbit/lessons/blink/challenges)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to turn on LED lights on the LED screen
|
||||
* learn how to turn off LED lights on the LED screen
|
||||
* learn how to pause program execution for the specified number of milliseconds
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* Understands that iteration is the repetition of a process such as a loop. (AL)
|
||||
|
||||
#### Programming & Development
|
||||
|
||||
* Creates programs that implement algorithms to achieve given goals. (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: 20 min.
|
||||
* [tutorial](/microbit/lessons/blink/tutorial)
|
||||
* [quiz](/microbit/lessons/blink/quiz)
|
||||
* [quiz answers](/microbit/lessons/blink/quiz-answers)
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/blink/challenges)
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/blink/challenges)
|
||||
|
||||
## Intended follow on
|
||||
|
||||
Publish script to the classroom.
|
||||
|
55
docs/reference/js/lessons/blink/activity.md
Normal file
55
docs/reference/js/lessons/blink/activity.md
Normal file
@ -0,0 +1,55 @@
|
||||
# blink activity
|
||||
|
||||
Turn an LED on and off with forever
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
### @video td/videos/blink-0
|
||||
|
||||
Let's learn how to blink an LED.
|
||||
|
||||
### ~
|
||||
|
||||
Have you ever tried to blink a flashlight at night? The concept is fairly simply: turn on the light, wait for a little, turn off the light, wait again, and repeat. That's exactly what we need to code to get a blinking LED.
|
||||
|
||||
Let's start by adding a line of code that turns on the LED at position ``2, 2``.
|
||||
|
||||
```
|
||||
led.plot(2, 2)
|
||||
```
|
||||
|
||||
Run your script to make sure it's correct. Then, let's add code to **pause** `500` milliseconds and turn off the LED.
|
||||
|
||||
```
|
||||
led.plot(2, 2)
|
||||
basic.pause(500)
|
||||
led.unplot(2, 2)
|
||||
```
|
||||
|
||||
We've got the LED blinking once. Let's add another pause and turn on the LED again.
|
||||
|
||||
```
|
||||
led.plot(2, 2)
|
||||
basic.pause(500)
|
||||
led.unplot(2, 2)
|
||||
basic.pause(500)
|
||||
led.plot(2, 2)
|
||||
```
|
||||
|
||||
The current code works but it only blinks once! We are going to use a `basic->forever` loop and move the code inside it to repeat it forever. We've dropped the second `led-plot` line since we don't need it in the loop.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
led.plot(2, 2)
|
||||
basic.pause(500)
|
||||
led.unplot(2, 2)
|
||||
basic.pause(500)
|
||||
})
|
||||
```
|
||||
|
||||
### ~avatar boothing
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/microbit/lessons/blink/challenges)!
|
||||
|
||||
### ~
|
||||
|
85
docs/reference/js/lessons/blink/challenges.md
Normal file
85
docs/reference/js/lessons/blink/challenges.md
Normal file
@ -0,0 +1,85 @@
|
||||
# blink challenges
|
||||
|
||||
Coding challenges for the blink tutorial #docs #challenges
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the [blink](/microbit/lessons/blink/activity) activity and your code will look like this:
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
led.plot(2, 2)
|
||||
basic.pause(200)
|
||||
led.unplot(2, 2)
|
||||
basic.pause(200)
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
### @video td/videos/blink-1
|
||||
|
||||
Let's display a "smiley face" on the screen! We'll start by plotting the eyes.
|
||||
|
||||
Add `led->plot (1,1)` and `led->plot(3,1)` under `led->plot(2,2)` ; then add `led->unplot(1,1)` and `led->unplot(3,1)` after pause. When you're ready, don't forget to run your code to try it out!
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
led.plot(2, 2)
|
||||
led.plot(1, 1)
|
||||
led.plot(3, 1)
|
||||
basic.pause(200)
|
||||
led.unplot(2, 2)
|
||||
led.unplot(1, 1)
|
||||
led.unplot(3, 1)
|
||||
basic.pause(200)
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 2
|
||||
|
||||
### @video td/videos/blink-2
|
||||
|
||||
Let's add the code to plot the mouth by plotting and unplotting `(1,4)`, `(2,4)` and `(3,4)`.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
led.plot(2, 2)
|
||||
led.plot(1, 1)
|
||||
led.plot(3, 1)
|
||||
led.plot(1, 4)
|
||||
led.plot(2, 4)
|
||||
led.plot(3, 4)
|
||||
basic.pause(200)
|
||||
led.unplot(2, 2)
|
||||
led.unplot(1, 1)
|
||||
led.unplot(3, 1)
|
||||
led.unplot(1, 4)
|
||||
led.unplot(2, 4)
|
||||
led.unplot(3, 4)
|
||||
basic.pause(200)
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 3
|
||||
|
||||
### @video td/videos/blink-3
|
||||
|
||||
Let's keep using `led->plot` to convert the mouth into a smiley face.
|
||||
|
||||
```` bitmatrix
|
||||
0 0 0 0 0
|
||||
0 1 0 1 0
|
||||
0 0 1 0 0
|
||||
1 0 0 0 1
|
||||
0 1 1 1 0
|
||||
````
|
||||
|
||||
### Challenge 4
|
||||
|
||||
Let's make it blink a bit faster. To do so, we need to reduce the amount of time used in ``basic->pause`` to ``100`` milliseconds.
|
||||
|
||||
### Challenge 5
|
||||
|
||||
Create your own image by changing the coordinates in `led->plot`!
|
||||
|
101
docs/reference/js/lessons/blink/lesson-plan.md
Normal file
101
docs/reference/js/lessons/blink/lesson-plan.md
Normal file
@ -0,0 +1,101 @@
|
||||
# blink lesson plan
|
||||
|
||||
Learn how to create a blinking LED script.
|
||||
|
||||
### @video vimeo/133778417
|
||||
|
||||
## Topic
|
||||
|
||||
Plot - Blinking LED
|
||||
|
||||
## Quick links
|
||||
|
||||
* [tutorial](/microbit/lessons/blink/tutorial)
|
||||
* [quiz](/microbit/js/blink/quiz)
|
||||
* [quiz answers](/microbit/lessons/blink/quiz-answers)
|
||||
* [challenges](/microbit/lessons/blink/challenges)
|
||||
|
||||
## 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 forever as well as simple commands, such as plot, pause, and clear screen.
|
||||
|
||||
## 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 Forever. Forever will repeats code in the background forever.
|
||||
|
||||
**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)
|
||||
* **clear screen**: [read more...](/microbit/reference/basic/clear-screen)
|
||||
* **forever**: [read more...](/microbit/reference/basic/forever)
|
||||
|
||||
## Resources
|
||||
|
||||
* Activity: [tutorial](/microbit/lessons/blink/tutorial)
|
||||
* Activity: [quiz](/microbit/lessons/blink/quiz)
|
||||
* Extended Activity: [challenges](/microbit/lessons/blink/challenges)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to blink a light
|
||||
* learn how to turn 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
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* Understands that iteration is the repetition of a process such as a loop. (AL)
|
||||
|
||||
#### Programming & Development
|
||||
|
||||
* Creates programs that implement algorithms to achieve given goals. (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: 20 min.
|
||||
* [tutorial](/microbit/lessons/blink/tutorial)
|
||||
* [quiz](/microbit/lessons/blink/quiz)
|
||||
* assessment opportunities: forever, plot, pause, clear screen
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/blink/challenges)
|
||||
* assessment opportunities: loops, plot, pause, clear screen
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/blink/challenges)
|
||||
|
||||
## Intended follow on
|
||||
|
||||
Publish script to the classroom.
|
||||
|
46
docs/reference/js/lessons/blink/quiz-answers.md
Normal file
46
docs/reference/js/lessons/blink/quiz-answers.md
Normal file
@ -0,0 +1,46 @@
|
||||
# blink quiz answers
|
||||
|
||||
Learn how to create a blinking LED script.
|
||||
|
||||
This is the answer key for the [blink quiz](/microbit/lessons/blink/quiz).
|
||||
|
||||
## 1. Describe what `led->plot` does?
|
||||
|
||||
Answers will vary. In general, plot refers to the code that turns on a specific LED. We specify the LED using x, y coordinates.
|
||||
|
||||
## 2. Draw which LED is ON after running this code
|
||||
|
||||
```
|
||||
led.plot(2, 2)
|
||||
```
|
||||
|
||||

|
||||
|
||||
By default, the position of an LED on *Blink Tutorial* is set to the centre of the screen. This code turns on the centre LED
|
||||
|
||||
## 3. Draw which LED is ON after running this code
|
||||
|
||||
```
|
||||
led.plot(0, 0)
|
||||
```
|
||||
|
||||

|
||||
|
||||
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)
|
||||
* ``y`` - the y coordinate or vertical position (0)
|
||||
|
||||
## 4. Draw which LED is ON after running this code
|
||||
|
||||
```
|
||||
led.plot(4, 4)
|
||||
```
|
||||
|
||||

|
||||
|
||||
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 (4)
|
||||
* ``y`` - the y coordinate or vertical position (4)
|
||||
|
40
docs/reference/js/lessons/blink/quiz.md
Normal file
40
docs/reference/js/lessons/blink/quiz.md
Normal file
@ -0,0 +1,40 @@
|
||||
# blink quiz
|
||||
|
||||
Learn how to create a blinking LED script.
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [blink tutorial](/microbit/lessons/blink/tutorial).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Describe what `led->plot` does?
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Draw which LED is ON after running this code
|
||||
|
||||
```
|
||||
led.plot(2, 2)
|
||||
```
|
||||
|
||||

|
||||
|
||||
## 3. Draw which LED is ON after running this code
|
||||
|
||||
```
|
||||
led.plot(0, 0)
|
||||
```
|
||||
|
||||

|
||||
|
||||
## 4. Draw which LED is ON after running this code
|
||||
|
||||
```
|
||||
led.plot(4, 4)
|
||||
```
|
||||
|
||||

|
||||
|
79
docs/reference/js/lessons/blinks-rectangle/challenges.md
Normal file
79
docs/reference/js/lessons/blinks-rectangle/challenges.md
Normal file
@ -0,0 +1,79 @@
|
||||
# rectangle explosion challenges
|
||||
|
||||
These challenges will allow you to make an exploding rectangle. #docs
|
||||
|
||||
**Challenge 0**
|
||||
|
||||
This [guided tutorial](https://test.microbit.co.uk/td/lessons/blinks-rectangle/tutorial) will help you show an animation forever!
|
||||
|
||||
First, let's make a small rectangle blink forever.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
basic.showAnimation(`
|
||||
. . . . . . . . . .
|
||||
. # # # . . . . . .
|
||||
. # # # . . . . . .
|
||||
. . . . . . . . . .
|
||||
. . . . . . . . . .
|
||||
`, 400)
|
||||
})
|
||||
```
|
||||
|
||||
**Challenge 1**
|
||||
|
||||
Let's begin creating our explosion effect by adding another rectangle animation that displays a slightly larger rectangle after the first one.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
basic.showAnimation(`
|
||||
. . . . . . . . . .
|
||||
. # # # . . . . . .
|
||||
. # # # . . . . . .
|
||||
. . . . . . . . . .
|
||||
. . . . . . . . . .
|
||||
`, 400)
|
||||
basic.showAnimation(`
|
||||
. . . . . . . . . .
|
||||
# # # # # . . . . .
|
||||
# # # # # . . . . .
|
||||
# # # # # . . . . .
|
||||
. . . . . . . . . .
|
||||
`, 400)
|
||||
})
|
||||
```
|
||||
|
||||
**Challenge 2**
|
||||
|
||||
To finalize our explosion effect, let's add a rectangle that is bigger than the last two we have created.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
basic.showAnimation(`
|
||||
. . . . . . . . . .
|
||||
. # # # . . . . . .
|
||||
. # # # . . . . . .
|
||||
. . . . . . . . . .
|
||||
. . . . . . . . . .
|
||||
`, 400)
|
||||
basic.showAnimation(`
|
||||
. . . . . . . . . .
|
||||
# # # # # . . . . .
|
||||
# # # # # . . . . .
|
||||
# # # # # . . . . .
|
||||
. . . . . . . . . .
|
||||
`, 400)
|
||||
basic.showAnimation(`
|
||||
# # # # # . . . . .
|
||||
# # # # # . . . . .
|
||||
# # # # # . . . . .
|
||||
# # # # # . . . . .
|
||||
# # # # # . . . . .
|
||||
`, 400)
|
||||
})
|
||||
```
|
||||
|
||||
**Challenge 3**
|
||||
|
||||
If you notice, the rectangle explodes fairly slow. Let's make it explode faster by decreasing the intervals of the animation from 400 to 200.
|
||||
|
91
docs/reference/js/lessons/boolean-fun/challenges.md
Normal file
91
docs/reference/js/lessons/boolean-fun/challenges.md
Normal file
@ -0,0 +1,91 @@
|
||||
# speed button challenges
|
||||
|
||||
This challenging script will create a game in which the user needs to press button A fast enough. You will get practice with using booleans in "if" statements. #docs
|
||||
|
||||
### Challenge 0
|
||||
|
||||
Welcome! This [guided tutorial](https://live.microbit.co.uk/td/lessons/speed-button/tutorial) will help you begin creating this game!
|
||||
|
||||
```
|
||||
counter = 0
|
||||
fastPress = false
|
||||
input.onButtonPressed("A", () => {
|
||||
counter = counter + 1
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
We need to know when the user has hit button `A` 15 times. The user wins when he/she is able to accomplish this in less than 3500 milliseconds (3.5 seconds). We can check for both conditions by using an `and` operator. When using an `and` operator, both conditions need to be true in order for the condition to be true.
|
||||
|
||||
```
|
||||
counter = 0
|
||||
fastPress = false
|
||||
input.onButtonPressed("A", () => {
|
||||
counter = counter + 1
|
||||
if (counter == 15 && input.runningTime() < 3500) {
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
Next, if the user has won, let's set our boolean to true. This indicates that he or she has won.
|
||||
|
||||
```
|
||||
counter = 0
|
||||
fastPress = false
|
||||
input.onButtonPressed("A", () => {
|
||||
counter = counter + 1
|
||||
if (counter == 15 && input.runningTime() < 3500) {
|
||||
fastPress = true // ***
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 2
|
||||
|
||||
We want to set `fastPress` to false if the user was too slow. To do so, we need another condition to see if the user took more than 3500 milliseconds (3.5 seconds). In the `if` statement, set `fastPress` to false.
|
||||
|
||||
```
|
||||
counter = 0
|
||||
fastPress = false
|
||||
input.onButtonPressed("A", () => {
|
||||
counter = counter + 1
|
||||
if (counter == 15 && input.runningTime() < 3500) {
|
||||
fastPress = true
|
||||
}
|
||||
if (counter == 15 && input.runningTime() > 3499) {
|
||||
fastPress = false // ***
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Now let's display if the user won or lost. To do so, we need to check the status of `fastPress` when the game is finished, and then show the correct message.
|
||||
|
||||
```
|
||||
counter = 0
|
||||
fastPress = false
|
||||
input.onButtonPressed("A", () => {
|
||||
counter = counter + 1
|
||||
if (counter == 15 && input.runningTime() < 3500) {
|
||||
fastPress = true
|
||||
}
|
||||
if (counter == 15 && input.runningTime() > 3499) {
|
||||
fastPress = false
|
||||
}
|
||||
if (counter == 15 && fastPress) {
|
||||
basic.showString("YOU WIN!", 150) // ***
|
||||
}
|
||||
if (counter == 15 && ! fastPress) {
|
||||
basic.showString("TOO SLOW!", 150) // ***
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
* Click the `run` button to see if the code runs properly.
|
||||
|
||||
### Challenge 4
|
||||
|
||||
Modify the code to change the difficulty level. Increasing the time will make it easier, while decreasing the time will make it harder. For example, changing the 3500 milliseconds to 4500 milliseconds will make the difficulty easier.
|
||||
|
97
docs/reference/js/lessons/bop-it.md
Normal file
97
docs/reference/js/lessons/bop-it.md
Normal file
@ -0,0 +1,97 @@
|
||||
# bop it lesson
|
||||
|
||||
a game where you have to keep up with the commands #var #data #if #random #min #max #mod #plot #unplot #pause #accceleration #docs
|
||||
|
||||
## Topic
|
||||
|
||||
Game Library
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [tutorial](/microbit/lessons/bop-it/tutorial)
|
||||
* [quiz](/microbit/lessons/bop-it/quiz)
|
||||
* [quiz answers](/microbit/lessons/bop-it/quiz-answers)
|
||||
* [challenges](/microbit/lessons/bop-it/challenges)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to create a minesweeper game with **if**, `if condition do` , **global variables** to keep track of the action that the player is asked to perform. We will be learning how to create a bop it game using functions, global variables, if (conditionals), input on button pressed, math random, logo down, add score, as well as simple commands such as show string.
|
||||
|
||||
## Documentation
|
||||
|
||||
* **game library** : [read more...](/microbit/js/game-library)
|
||||
* **global variables** : [read more...](/microbit/js/data)
|
||||
* **assignment operator** : [read more...](/microbit/reference/variables/assignment)
|
||||
* **functions** : [read more...](/microbit/js/function)
|
||||
* **call** : [read more...](/microbit/js/call)
|
||||
* **math random number** : [read more...](/microbit/js/math)
|
||||
* **on button pressed** : [read more...](/microbit/reference/input/on-button-pressed)
|
||||
* **on logo down** : [read more...](/microbit/functions/on-logo-down)
|
||||
* **on shake** : [read more...](/microbit/reference/input/on-gesture)
|
||||
* **if** : [read more...](/microbit/reference/logic/if)
|
||||
* **show number** : [read more...](/microbit/reference/basic/show-number)
|
||||
* **show string** : [read more...](/microbit/reference/basic/show-string)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how the game library supports single-player, time-based games: a game library supports setting a number of lives, score, countdown clock, and levels.
|
||||
* learn how to create a global variable as a place where you can store data so that you can use it later in your code, accessible across functions and in nested code blocks
|
||||
* learn how the assignment operator is used to declare a new variable or update the value of a variable
|
||||
* learn how to create a function as a unit of code that performs a specific task and returns a result to make the code easier to read, debug, and update
|
||||
* learn how to call an existing function in the script
|
||||
* learn how to return a random number
|
||||
* learn how to run code when an input button is pressed
|
||||
* learn how to run code when the BBC micro:bit is oriented perpendicularly to the floor with the logo down
|
||||
* learn how to run code when the BBC micro:bit is shaken; when running code in the web browser, moving the mouse quickly simulates shaking
|
||||
* learn how to conditionally run code depending on whether a condition is true or not
|
||||
* learn how to show a string of the LED screen one character at a time (scrolling left to right)
|
||||
* learn how to show a number on the LED screen one digit at a time (scrolling left to right)
|
||||
|
||||
## Links to the National Curriculum Programmes of Study for Computing
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* Designs solutions (algorithms) that use repetition and two-way selection, ie if, then and else.(AL)
|
||||
* Uses logical reasoning to predict outputs, showing an awareness of inputs (AL)
|
||||
* Represents solutions using a structured notation (AL) (AB)
|
||||
|
||||
#### Programming & Development
|
||||
|
||||
* Creates programs that implement algorithms to achieve given goals (AL)
|
||||
* Declares and assigns variables(AB)
|
||||
* Understands the difference between, and appropriately uses if and if, then and else statements(AL)
|
||||
* Uses a range of operators and expressions e.g. Boolean, and applies them in the context of program control. (AL)
|
||||
* Selects the appropriate data types(AL) (AB
|
||||
|
||||
#### Data & Data Representation
|
||||
|
||||
* Understands the difference between data and information(AB)
|
||||
* Performs more complex searches for information e.g. using Boolean and relational operators(AL) (GE) (EV)
|
||||
|
||||
#### Hardware & Processing
|
||||
|
||||
* Knows that computers collect data from various input devices, including sensors and application software (AB)
|
||||
|
||||
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation
|
||||
|
||||
## Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [tutorial](/microbit/lessons/bop-it/tutorial)
|
||||
* [quiz](/microbit/lessons/bop-it/quiz)
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/bop-it/challenges)
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/bop-it/challenges)
|
||||
|
87
docs/reference/js/lessons/bop-it/challenges.md
Normal file
87
docs/reference/js/lessons/bop-it/challenges.md
Normal file
@ -0,0 +1,87 @@
|
||||
# bop it challenges
|
||||
|
||||
a game similar to "Simon Says" with the BBC micro:bit. #docs
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following guided tutorial:
|
||||
|
||||
* [tutorial](/microbit/lessons/bop-it/tutorial)
|
||||
|
||||
At the end of the tutorial, click `keep editing`. Your code should look like this:
|
||||
|
||||
```
|
||||
newAction() // ***
|
||||
input.onButtonPressed("A", () => {
|
||||
if (action == 0) {
|
||||
game.addScore(1) // ***
|
||||
newAction() // ***
|
||||
}
|
||||
}) // ***
|
||||
input.onLogoDown(() => {
|
||||
if (action == 1) {
|
||||
game.addScore(1) // ***
|
||||
newAction() // ***
|
||||
}
|
||||
}) // ***
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
if (action == 2) {
|
||||
game.addScore(1) // ***
|
||||
newAction() // ***
|
||||
}
|
||||
}) // ***
|
||||
input.onButtonPressed("B", () => {
|
||||
basic.showNumber(game.score(), 150) // ***
|
||||
basic.pause(2000) // ***
|
||||
newAction() // ***
|
||||
}) // ***
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Now let's add some more types of instructions for the player to follow. Let's add `PRESS PIN 0`. Change the global variable `action` to `math->random(4)` so that we can add a new **IF** statement that checks if `action=3`. If it does, display instructions to press pin 0.
|
||||
|
||||
```
|
||||
/**
|
||||
* {highlight}
|
||||
*/
|
||||
export function newAction_() {
|
||||
action = Math.random(4) // ***
|
||||
if (action == 0) {
|
||||
basic.showString("PUSH A", 150) // ***
|
||||
}
|
||||
if (action == 1) {
|
||||
basic.showString("LOGO DOWN", 150) // ***
|
||||
}
|
||||
if (action == 2) {
|
||||
basic.showString("SHAKE", 150) // ***
|
||||
}
|
||||
if (action == 3) {
|
||||
basic.showString("PRESS PIN 0", 150) // ***
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Now let's implement `PRESS PIN 0` in the main. Create a condition of `input->on pin pressed("P0")` that will add one to the score and calls the method `new action`.
|
||||
|
||||
```
|
||||
// **. . .**
|
||||
input.onButtonPressed("B", () => {
|
||||
basic.showNumber(game.score(), 150) // ***
|
||||
basic.pause(2000) // ***
|
||||
newAction() // ***
|
||||
}) // ***
|
||||
input.onPinPressed("P0", () => {
|
||||
if (action == 3) {
|
||||
game.addScore(1) // ***
|
||||
newAction() // ***
|
||||
}
|
||||
}) // ***
|
||||
```
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Add `POINT ME NORTH` to the list of possible commands.
|
||||
|
86
docs/reference/js/lessons/bop-it/quiz-answers.md
Normal file
86
docs/reference/js/lessons/bop-it/quiz-answers.md
Normal file
@ -0,0 +1,86 @@
|
||||
# bop it quiz answers
|
||||
|
||||
a game where you have to keep up with the commands #math #random #docs
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [bop it tutorial](/microbit/lessons/bop-it/tutorial).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Write the code that will store the global variable named 'action' and returns a random number between 0 and 2
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
action = Math.random(3)
|
||||
```
|
||||
|
||||
## 2. Write the code that will display the string, "PUSH A" if the global variable called 'action' is equal to 0
|
||||
|
||||
<br />
|
||||
|
||||
```
|
||||
if (action == 0) {
|
||||
basic.showString("PUSH A", 150)
|
||||
}
|
||||
```
|
||||
|
||||
## 3. Write the code that increments the score if button A is pressed when the global variable called 'action' is equal to 1
|
||||
|
||||
<br />
|
||||
|
||||
```
|
||||
input.onButtonPressed("A", () => {
|
||||
if (action == 0) {
|
||||
game.addScore(1)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## 4. Write the code that will display the string "LOGO DOWN" if the global variable called 'action' is equal to 1
|
||||
|
||||
<br />
|
||||
|
||||
```
|
||||
if (action == 1) {
|
||||
basic.showString("LOGO DOWN", 150)
|
||||
}
|
||||
```
|
||||
|
||||
## 5. Write the code that increments the score if the BBC micro:bit logo is tilted down when the global variable called 'action' is equal to 1
|
||||
|
||||
<br />
|
||||
|
||||
```
|
||||
input.onLogoDown(() => {
|
||||
if (action == 1) {
|
||||
game.addScore(1)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## 6. Write the code that will display the string "SHAKE" if the global variable called 'action' is equal to 2
|
||||
|
||||
<br />
|
||||
|
||||
```
|
||||
if (action == 2) {
|
||||
basic.showString("SHAKE", 150)
|
||||
}
|
||||
```
|
||||
|
||||
## 7. Write the code that increments the score if the BBC micro:bit is shaken when the global variable called 'action' is equal to 2
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
input.onLogoDown(() => {
|
||||
if (action == 1) {
|
||||
game.addScore(1)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
40
docs/reference/js/lessons/bop-it/quiz.md
Normal file
40
docs/reference/js/lessons/bop-it/quiz.md
Normal file
@ -0,0 +1,40 @@
|
||||
# bop it quiz
|
||||
|
||||
a game where you have to keep up with the commands #math #random #docs
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [bop it tutorial](/microbit/lessons/bop-it/tutorial).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Write the code that will store the global variable named 'action' and returns a random number between 0 and 2
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Write the code that will display the string, "PUSH A" if the global variable called 'action' is equal to 0
|
||||
|
||||
<br />
|
||||
|
||||
## 3. Write the code that increments the score if button A is pressed when the global variable called 'action' is equal to 1
|
||||
|
||||
<br />
|
||||
|
||||
## 4. Write the code that will display the string "LOGO DOWN" if the global variable called 'action' is equal to 1
|
||||
|
||||
<br />
|
||||
|
||||
## 5. Write the code that increments the score if the BBC micro:bit logo is tilted down when the global variable called 'action' is equal to 1
|
||||
|
||||
<br />
|
||||
|
||||
<br />
|
||||
|
||||
## 6. Write the code that will display the string "SHAKE" if the global variable called 'action' is equal to 2
|
||||
|
||||
<br />
|
||||
|
||||
## 7. Write the code that increments the score if the BBC micro:bit is shaken when the global variable called 'action' is equal to 2
|
||||
|
108
docs/reference/js/lessons/bounce-image.md
Normal file
108
docs/reference/js/lessons/bounce-image.md
Normal file
@ -0,0 +1,108 @@
|
||||
# bounce image lesson
|
||||
|
||||
scroll an image across the screen #animation #docs
|
||||
|
||||
### @video td/videos/bounce-image-0
|
||||
|
||||
## Topic
|
||||
|
||||
Basic- Show Animation
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [tutorial](/microbit/lessons/bounce-image/tutorial)
|
||||
* [quiz](/microbit/lessons/bounce-image/quiz)
|
||||
* [quiz answers](/microbit/lessons/bounce-image/quiz-answers)
|
||||
* [challenges](/microbit/lessons/bounce-image/challenges)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning / place of lesson in scheme of work
|
||||
|
||||
Learn how to creating an **animation**, `basic->show animation` to display a series of images. We will be learning how to create a counter app using a forever loop, the input on shake, and show animation.
|
||||
|
||||
## What the teacher needs to know / QuickStart Computing Glossary
|
||||
|
||||
* Algorithm: An unambiguous set of rules or a precise step-by-step guide to solve a problem or achieve a particular objective.
|
||||
* Command: An instruction for the computer to execute, written in a particular programming language.
|
||||
* Hardware: The physical systems and components of digital devices; see also software.
|
||||
* Input: Data provided to a computer system, such as via a keyboard, mouse, microphone, camera or physical sensors.
|
||||
* Loop: A block of code repeated automatically under the program’s control.
|
||||
* Output: The information produced by a computer system for its user, typically on a screen, through speakers or on a printer, but possibly through the control of motors in physical systems.
|
||||
* Programmable toys: Robots designed for children to use, accepting input, storing short sequences of simple instructions and moving according to this stored program.
|
||||
* 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.
|
||||
* Selection: A programming construct in which one section of code or another is executed depending on whether a particular condition is met.
|
||||
* Sequence: To place program instructions in order, with each executed one after the other.
|
||||
* Simulation: Using a computer to model the state and behaviour of real-world (or imaginary) systems, including physical or social systems; an integral part of most computer games.
|
||||
|
||||
## Documentation
|
||||
|
||||
* **forever** : [read more...](/microbit/reference/basic/forever)
|
||||
* **show animation** : [read more...](/microbit/reference/basic/show-animation)
|
||||
* **on shake** : [read more...](/microbit/reference/input/on-gesture)
|
||||
|
||||
## Resources
|
||||
|
||||
* Activity: [tutorial](/microbit/lessons/bounce-image/tutorial)
|
||||
* Activity: [quiz](/microbit/lessons/bounce-image/quiz)
|
||||
* Extended Activity: [challenges](/microbit/lessons/bounce-image/challenges)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to repeat code in the background forever
|
||||
* learn how to show a series of image frames on the LED screen, pausing the specified time after each frame
|
||||
* learn how to run code when the micro:bit is shaken; when running code in the web browser, moving the mouse quickly simulates shaking
|
||||
|
||||
## Links to the National Curriculum Programmes of Study for Computing
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* Uses diagrams to express solutions.(AB)
|
||||
* 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)
|
||||
* Selects the appropriate data types(AL) (AB)
|
||||
|
||||
#### Hardware & Processing
|
||||
|
||||
* Knows that computers collect data from various input devices, including sensors and application software (AB)
|
||||
|
||||
#### Communication Networks
|
||||
|
||||
* Demonstrates responsible use of technologies and online services, and knows a range of ways to report concerns Understands how search engines rank search results (AL)
|
||||
|
||||
#### Information Technology
|
||||
|
||||
* Collects, organizes, 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)
|
||||
* Recognises ethical issues surrounding the application of information technology beyond school.
|
||||
|
||||
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation
|
||||
|
||||
## Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [tutorial](/microbit/lessons/bounce-image/tutorial)
|
||||
* [quiz](/microbit/lessons/bounce-image/quiz)
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/bounce-image/challenges)
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/bounce-image/challenges)
|
||||
|
||||
## Intended follow on
|
||||
|
||||
Publish script to the classroom.
|
||||
|
90
docs/reference/js/lessons/bounce-image/challenges.md
Normal file
90
docs/reference/js/lessons/bounce-image/challenges.md
Normal file
@ -0,0 +1,90 @@
|
||||
# bounce image challenges
|
||||
|
||||
Coding challenges for the bounce image tutorial. #docs
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following guided tutorial:
|
||||
|
||||
* [tutorial](/microbit/lessons/bounce-image/tutorial)
|
||||
|
||||
At the end of the tutorial, click `keep editing`. Your code should look like this:
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
basic.showAnimation(`
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . #
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . #
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . #
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . #
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . #
|
||||
`, 200)
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
### @video td/videos/bounce-image-1
|
||||
|
||||
Now, let's add frames to reverse the animation so it looks like the bar is bouncing off the right edge of the display.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
basic.showAnimation(`
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . # . . . # . . . # . . . # . . . # . . . .
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . # . . . # . . . # . . . # . . . # . . . .
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . # . . . # . . . # . . . # . . . # . . . .
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . # . . . # . . . # . . . # . . . # . . . .
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . # . . . # . . . # . . . # . . . # . . . .
|
||||
`, 200) // ***
|
||||
})
|
||||
```
|
||||
|
||||
* Run the code to see if it works as expected.
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Let's add a condition for on shake!
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
basic.showAnimation(`
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . # . . . # . . . # . . . # . . . # . . . .
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . # . . . # . . . # . . . # . . . # . . . .
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . # . . . # . . . # . . . # . . . # . . . .
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . # . . . # . . . # . . . # . . . # . . . .
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . # . . . # . . . # . . . # . . . # . . . .
|
||||
`, 200)
|
||||
})
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
}) // ***
|
||||
```
|
||||
|
||||
**Challenge 3**
|
||||
|
||||
### @video td/videos/bounce-image-2-3
|
||||
|
||||
When the BBC micro:bit is shaken we want to show a new animation. Here is an example, but you can create your own. Be creative!
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
basic.showAnimation(`
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . # . . . # . . . # . . . # . . . # . . . .
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . # . . . # . . . # . . . # . . . # . . . .
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . # . . . # . . . # . . . # . . . # . . . .
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . # . . . # . . . # . . . # . . . # . . . .
|
||||
# . . . . . # . . . . . # . . . . . # . . . . . # . . . # . . . # . . . # . . . # . . . .
|
||||
`, 200)
|
||||
})
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
basic.showAnimation(`
|
||||
. . . . . . . . . . # # # # # . . . . . . . . . .
|
||||
. . . . . . # # # . # # # # # . # # # . . . . . .
|
||||
. . # . . . # # # . # # # # # . # # # . . . # . .
|
||||
. . . . . . # # # . # # # # # . # # # . . . . . .
|
||||
. . . . . . . . . . # # # # # . . . . . . . . . .
|
||||
`, 200) // ***
|
||||
})
|
||||
```
|
||||
|
||||
* Run the code to see if it works as expected.
|
60
docs/reference/js/lessons/bounce-image/quiz-answers.md
Normal file
60
docs/reference/js/lessons/bounce-image/quiz-answers.md
Normal file
@ -0,0 +1,60 @@
|
||||
# bounce image quiz answers
|
||||
|
||||
scroll an image on the BBC micro:bit #LED #screen #animation #docs
|
||||
|
||||
This is the answer key for the [bounce image quiz](/microbit/lessons/bounce-image/quiz).
|
||||
|
||||
## 1. What does it mean to 'add frames' ?
|
||||
|
||||
Adding frames modifies the animation by including more still images in each animation.
|
||||
|
||||
## 2. Write the code that will display this animation.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
# . . . .
|
||||
# . . . .
|
||||
# . . . .
|
||||
# . . . .
|
||||
# . . . .
|
||||
`, 400)
|
||||
```
|
||||
|
||||
## 3. Write the code that will display this animation with two frames.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
# . . . . . # . . .
|
||||
# . . . . . # . . .
|
||||
# . . . . . # . . .
|
||||
# . . . . . # . . .
|
||||
# . . . . . # . . .
|
||||
`, 400)
|
||||
```
|
||||
|
||||
## 4. Write the code that will display this animation with three frames.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
# . . . . . # . . . . . # . .
|
||||
# . . . . . # . . . . . # . .
|
||||
# . . . . . # . . . . . # . .
|
||||
# . . . . . # . . . . . # . .
|
||||
# . . . . . # . . . . . # . .
|
||||
`, 400)
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
40
docs/reference/js/lessons/bounce-image/quiz.md
Normal file
40
docs/reference/js/lessons/bounce-image/quiz.md
Normal file
@ -0,0 +1,40 @@
|
||||
# bounce image quiz
|
||||
|
||||
scroll an image on the BBC micro:bit #LED #screen #animation #docs
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this document to guide your work in the [bounce image tutorial](/microbit/lessons/bounce-image/tutorial) !
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. What does it mean to 'add frames' ?
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Write the code that will display this animation.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Write the code that will display this animation with two frames.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 4. Write the code that will display this animation with three frames.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
85
docs/reference/js/lessons/boxer-mania/challenges.md
Normal file
85
docs/reference/js/lessons/boxer-mania/challenges.md
Normal file
@ -0,0 +1,85 @@
|
||||
# boxer mania challenges
|
||||
|
||||
My script. #docs
|
||||
|
||||
This [guided tutorial](/microbit/lessons/boxer-mania/tutorial) will help you create an animation!
|
||||
|
||||
**Challenge 0**
|
||||
|
||||
Let's create and show a series of frames on the LED screen; this is an animation!
|
||||
|
||||
We will use multiple frames to make it look like a square is rotating on the micro:bit screen!
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
. # . . .
|
||||
# . . . .
|
||||
. # . . .
|
||||
. . # . #
|
||||
. . . # .
|
||||
`, 400)
|
||||
```
|
||||
|
||||
**Challenge 1**
|
||||
|
||||
Let's create the next frame to make it look like the square is spinning clock-wise!
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
. # . . .
|
||||
# . . . .
|
||||
. # . . .
|
||||
. . # . #
|
||||
. . . # .
|
||||
`, 400)
|
||||
basic.showAnimation(`
|
||||
# # # # #
|
||||
# . . . #
|
||||
# . . . #
|
||||
# . . . #
|
||||
# # # # #
|
||||
`, 400) // ***
|
||||
```
|
||||
|
||||
**Challenge 2**
|
||||
|
||||
Add the next two frames to show a complete rotation for the square!
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
. # . . .
|
||||
# . . . .
|
||||
. # . . .
|
||||
. . # . #
|
||||
. . . # .
|
||||
`, 400)
|
||||
basic.showAnimation(`
|
||||
# # # # #
|
||||
# . . . #
|
||||
# . . . #
|
||||
# . . . #
|
||||
# # # # #
|
||||
`, 400)
|
||||
basic.showAnimation(`
|
||||
. # . . . # # # # #
|
||||
# . # . . # . . . #
|
||||
. . . # . # . . . #
|
||||
. . . . # # . . . #
|
||||
. . . # . # # # # #
|
||||
`, 400) // ***
|
||||
```
|
||||
|
||||
**Challenge 3**
|
||||
|
||||
Do you want to show the same animation with fewer lines of codes? We can do this by combining all the frames into one show animation function call!
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
. # . . . # # # # # . # . . . # # # # #
|
||||
# . . . . # . . . # # . # . . # . . . #
|
||||
. # . . . # . . . # . . . # . # . . . #
|
||||
. . # . # # . . . # . . . . # # . . . #
|
||||
. . . # . # # # # # . . . # . # # # # #
|
||||
`, 400) // ***
|
||||
```
|
||||
|
86
docs/reference/js/lessons/break/challenges.md
Normal file
86
docs/reference/js/lessons/break/challenges.md
Normal file
@ -0,0 +1,86 @@
|
||||
# break challenges
|
||||
|
||||
This guide will show you how to use a break statement within a while loop. #docs
|
||||
|
||||
### Challenge 0
|
||||
|
||||
Welcome! This [guided tutorial](/microbit/lessons/break/tutorial) will assist you with this activity.
|
||||
|
||||
```
|
||||
count = 0
|
||||
shouldBreak = false
|
||||
input.onButtonPressed("A", () => {
|
||||
shouldBreak = true
|
||||
})
|
||||
while (true) {
|
||||
if (shouldBreak) {
|
||||
basic.showString("I'M OUT!", 150)
|
||||
images.createImage(`
|
||||
# . . . #
|
||||
# . . . #
|
||||
. . # . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`).showImage(0)
|
||||
break
|
||||
}
|
||||
count = count + 1
|
||||
basic.showNumber(count, 150)
|
||||
basic.pause(1000)
|
||||
}
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Try to remove the `break` in the `if` loop. What problem does this create?
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Now let's resume the timer again once button `B` is pressed! To do so, begin by creating a condition to know when button `B` is pressed.
|
||||
|
||||
```
|
||||
// **. . .**
|
||||
while (true) {
|
||||
if (shouldBreak) {
|
||||
basic.showString("I'M OUT!", 150)
|
||||
break
|
||||
}
|
||||
count = count + 1
|
||||
basic.showNumber(count, 150)
|
||||
basic.pause(1000)
|
||||
}
|
||||
input.onButtonPressed("B", () => {
|
||||
}) // ***
|
||||
```
|
||||
|
||||
Next, set `shouldBreak` back to false to indicate we want to run the `while` loop again.
|
||||
|
||||
```
|
||||
// **. . .**
|
||||
input.onButtonPressed("B", () => {
|
||||
shouldBreak = false // ***
|
||||
})
|
||||
```
|
||||
|
||||
And now copy the code from the previous while loop into the condition of `input->on button pressed("B")`. This will resume the counter.
|
||||
|
||||
```
|
||||
// **. . .**
|
||||
input.onButtonPressed("B", () => {
|
||||
shouldBreak = false
|
||||
while (true) {
|
||||
if (shouldBreak) {
|
||||
basic.showString("I'M OUT!", 150) // ***
|
||||
break // ***
|
||||
}
|
||||
count = count + 1 // ***
|
||||
basic.showNumber(count, 150) // ***
|
||||
basic.pause(1000) // ***
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Notice that the two `while` loops are identical. Clean up this redundancy in your code by creating another method and then placing the `while` loop in the method.
|
||||
|
52
docs/reference/js/lessons/button/challenges.md
Normal file
52
docs/reference/js/lessons/button/challenges.md
Normal file
@ -0,0 +1,52 @@
|
||||
# button challenges
|
||||
|
||||
My script. #docs
|
||||
|
||||
### Challenge 0
|
||||
|
||||
Howdy! This [guided tutorial](/microbit/rxqgzy) will help you complete this activity!
|
||||
|
||||
In this guide, you will learn how to use buttons and show text on the screen. Let's start by adding to respond **when the left button is pressed**.
|
||||
|
||||
```
|
||||
input.onButtonPressed("A", () => {
|
||||
})
|
||||
```
|
||||
|
||||
All the code inside `input->on button pressed` runs when the button is pressed. Let's add the code to show some text.
|
||||
|
||||
```
|
||||
input.onButtonPressed("A", () => {
|
||||
basic.showString("hello", 150)
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Let's add an event handler for Button `B`.
|
||||
|
||||
```
|
||||
input.onButtonPressed("A", () => {
|
||||
basic.showString("hello", 150)
|
||||
})
|
||||
input.onButtonPressed("B", () => {
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Display `bye` when the `B` button is pressed.
|
||||
|
||||
```
|
||||
input.onButtonPressed("A", () => {
|
||||
basic.showString("hello", 150)
|
||||
})
|
||||
input.onButtonPressed("B", () => {
|
||||
basic.showString("bye", 150)
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Change the strings so that they display some other text. In order to do so, you will need to edit what is inside the quotation marks in `basic->show string`.
|
||||
|
128
docs/reference/js/lessons/cascade/quiz.md
Normal file
128
docs/reference/js/lessons/cascade/quiz.md
Normal file
@ -0,0 +1,128 @@
|
||||
# strobe lightquiz
|
||||
|
||||
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 [light column cascade tutorial](/microbit/js/light-column-cascade/tutorial).
|
||||
|
||||
Answer the questions below while working on or after you finish the tutorial. Pay attention to the dialogs!
|
||||
|
||||
## 1. What is a for loop?
|
||||
|
||||
## 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 all the locations where the LED is lighted. Explain why the LED is lighted there.
|
||||
|
||||

|
||||
|
||||
## 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 all the locations where the LED is lighted. Explain why the LED is lighted there.
|
||||
|
||||

|
||||
|
||||
## 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.
|
||||
|
||||

|
||||
|
||||
******************************
|
||||
|
||||
## ANSWER KEY
|
||||
|
||||
## Directions
|
||||
|
||||
Answer the questions below while working on or after you finish the tutorial.
|
||||
|
||||
## 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 i3 = 0; i3 < 5; i3++) {
|
||||
for (let j3 = 0; j3 < 5; j3++) {
|
||||
led.plot(i3, j3)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
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 i4 = 0; i4 < 3; i4++) {
|
||||
for (let j4 = 0; j4 < 3; j4++) {
|
||||
led.plot(i4, j4)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
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 i5 = 0; i5 < 2; i5++) {
|
||||
for (let j5 = 0; j5 < 2; j5++) {
|
||||
led.plot(i5, j5)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
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)
|
||||
|
91
docs/reference/js/lessons/catch-the-egg-game.md
Normal file
91
docs/reference/js/lessons/catch-the-egg-game.md
Normal file
@ -0,0 +1,91 @@
|
||||
# catch the egg game lesson
|
||||
|
||||
a game to catch eggs in a basket #var #data #if #random #min #max #mod #plot #unplot #pause #accceleration #docs
|
||||
|
||||
### @video td/videos/catch-the-egg-game-0
|
||||
|
||||
## Topic
|
||||
|
||||
Variables
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [tutorial](/microbit/lessons/catch-the-egg-game/tutorial)
|
||||
* [quiz](/microbit/lessons/catch-the-egg-game/quiz)
|
||||
* [quiz answers](/microbit/lessons/catch-the-egg-game/quiz-answers)
|
||||
* [challenges](/microbit/lessons/catch-the-egg-game/challenges)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to create a catch the egg game game with **plot**, `led->plot` , **unplot**, `led->unplot`, and **acceleration** `input -> acceleration` to turn on and off LED lights on the LED screen. We will be learning how to create a catch the egg game app using global variables, forever loop, local variable, input acceleration, math min, math max, math random, math mod, if (conditionals), game library as well as simple commands, such as led plot, led unplot, and pause.
|
||||
|
||||
## Documentation
|
||||
|
||||
* **variables** : [read more...](/microbit/reference/variables/var)
|
||||
* **forever** : [read more...](/microbit/reference/basic/forever)
|
||||
* **unplot** : [read more...](/microbit/reference/led/unplot)
|
||||
* **plot** : [read more...](/microbit/reference/led/plot)
|
||||
* **if** : [read more...](/microbit/reference/logic/if)
|
||||
* **acceleration** : [read more...](/microbit/reference/input/acceleration)
|
||||
* **math minimum number** : [read more...](/microbit/js/math)
|
||||
* **math maximum number** : [read more...](/microbit/js/math)
|
||||
* **math random number** : [read more...](/microbit/js/math)
|
||||
* **math modulus** : [read more...](/microbit/js/math)
|
||||
* **show number** : [read more...](/microbit/reference/basic/show-number)
|
||||
* **pause** : [read more...](/microbit/reference/basic/pause)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to create a global variable as a place where you can store data so that you can use it later in your code, accessible across functions and in nested code blocks
|
||||
* learn how to repeat code in the background forever
|
||||
* learn how to turn off a LED light on the LED screen
|
||||
* learn how to turn on a LED light on the LED screen
|
||||
* learn how to learn how to conditionally run code depending on whether a condition is true or not
|
||||
* learn how to learn how to get the acceleration value (g-force), in one of three specified dimensions
|
||||
* learn how to return the smaller of two numbers
|
||||
* learn how to return the larger of two numbers
|
||||
* learn how to return a random number
|
||||
* learn how to return the modulus
|
||||
* learn how to show a number of the BBC micro:bit screen
|
||||
* learn how to pause your code for the specified number of milliseconds
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* Designs solutions (algorithms) that use repetition and two-way selection, ie if, then and else.(AL)
|
||||
* Uses logical reasoning to predict outputs, showing an awareness of inputs (AL)
|
||||
* Recognises that different solutions exist for the same problem (AL) (AB) 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)
|
||||
* Declares and assigns variables(AB)
|
||||
* Understands the difference between, and appropriately uses if and if, then and else statements(AL)
|
||||
* Uses a variable and relational operators within a loop to govern termination (AL) (GE)
|
||||
* Has practical experience of a high-level textual language, including using standard libraries when programming(AB) (AL)
|
||||
* Uses a range of operators and expressions e.g. Boolean, and applies them in the context of program control. (AL)
|
||||
* Selects the appropriate data types(AL) (AB
|
||||
|
||||
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation
|
||||
|
||||
## Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [tutorial](/microbit/lessons/catch-the-egg-game/tutorial)
|
||||
* [quiz](/microbit/lessons/catch-the-egg-game/quiz)
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/catch-the-egg-game/challenges)
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/catch-the-egg-game/challenges)
|
||||
|
163
docs/reference/js/lessons/catch-the-egg-game/challenges.md
Normal file
163
docs/reference/js/lessons/catch-the-egg-game/challenges.md
Normal file
@ -0,0 +1,163 @@
|
||||
# catch the egg game challenges
|
||||
|
||||
Coding challenges for catch the egg game.
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following guided tutorial:
|
||||
|
||||
* [tutorial](/microbit/lessons/catch-the-egg-game/tutorial)
|
||||
|
||||
At the end of the tutorial, click `keep editing`. Your code should look like this:
|
||||
|
||||
```
|
||||
let basketX = 2
|
||||
let eggX = 2
|
||||
let eggY = 0
|
||||
basic.forever(() => {
|
||||
led.unplot(basketX, 4)
|
||||
led.unplot(eggX, eggY)
|
||||
eggY = eggY + 1
|
||||
led.plot(eggX, eggY)
|
||||
basic.pause(300)
|
||||
let accX = input.acceleration("x")
|
||||
basketX = 2 + Math.min(2, Math.max(-2, accX / 200))
|
||||
led.plot(basketX, 4)
|
||||
if (eggY > 4) {
|
||||
eggY = -1
|
||||
eggX = Math.random(5)
|
||||
}
|
||||
basic.pause(300)
|
||||
})
|
||||
```
|
||||
|
||||
### ~avatar avatar impressed
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Let's start by adding the **game** library.
|
||||
|
||||
### ~
|
||||
|
||||
### ~avatar avatar improvised
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Let's use an **IF** statement to detect if the egg and the basket are lined up.
|
||||
|
||||
Now that we know when an egg is caught, we can keep track of the score! We need to use the `add score` function built into the game library to add `1` point for every egg that is caught. However, let's not forget to `remove life` if an egg falls off the display before it's caught!
|
||||
|
||||
### ~
|
||||
|
||||
```
|
||||
let basketX1 = 2
|
||||
let eggX1 = 2
|
||||
let eggY1 = 0
|
||||
basic.forever(() => {
|
||||
led.unplot(basketX1, 4)
|
||||
led.unplot(eggX1, eggY1)
|
||||
eggY1 = eggY1 + 1
|
||||
led.plot(eggX1, eggY1)
|
||||
basic.pause(300)
|
||||
let accX1 = input.acceleration("x")
|
||||
basketX1 = 2 + Math.min(2, Math.max(-2, accX1 / 200))
|
||||
led.plot(basketX1, 4)
|
||||
if (eggY1 > 4) {
|
||||
eggY1 = -1
|
||||
eggX1 = Math.random(5)
|
||||
}
|
||||
if (eggY1 == 4) {
|
||||
if (basketX1 == eggX1) {
|
||||
game.addScore(1) // ***
|
||||
} else {
|
||||
game.removeLife(1) // ***
|
||||
}
|
||||
}
|
||||
basic.pause(300)
|
||||
})
|
||||
```
|
||||
|
||||
* Press the `run` button to test out your game.
|
||||
|
||||
### ~avatar avatar encourage
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Catching eggs gets easier with practice so let's make the eggs fall faster every 5 catches. We can do this by tracking how long the egg pauses in each position while falling with a global variable called **falling pause**. Let's create this variable and set it to `300` initially. Don't forget to also create a condition that will be true every 5 catches.
|
||||
|
||||
### ~
|
||||
|
||||
```
|
||||
let basketX2 = 2
|
||||
let eggX2 = 2
|
||||
let eggY2 = 0
|
||||
let fallingPause = 300 // ***
|
||||
basic.forever(() => {
|
||||
led.unplot(basketX2, 4)
|
||||
led.unplot(eggX2, eggY2)
|
||||
eggY2 = eggY2 + 1
|
||||
led.plot(eggX2, eggY2)
|
||||
basic.pause(300)
|
||||
let accX2 = input.acceleration("x")
|
||||
basketX2 = 2 + Math.min(2, Math.max(-2, accX2 / 200))
|
||||
led.plot(basketX2, 4)
|
||||
if (eggY2 > 4) {
|
||||
eggY2 = -1
|
||||
eggX2 = Math.random(5)
|
||||
}
|
||||
if (eggY2 == 4) {
|
||||
if (basketX2 == eggX2) {
|
||||
game.addScore(1)
|
||||
if (math.mod(game.score(), 5) == 0) {
|
||||
}
|
||||
} else {
|
||||
game.removeLife(1)
|
||||
}
|
||||
}
|
||||
basic.pause(300)
|
||||
})
|
||||
```
|
||||
|
||||
### ~avatar avatar surprised
|
||||
|
||||
### Challenge 4
|
||||
|
||||
### @video td/videos/catch-the-egg-game-4
|
||||
|
||||
Let's make the egg fall faster by decreasing the amount of time it pauses in each position by decreasing **falling pause** by `25` every 5 catches. Now, instead of pausing for 300 milliseconds we can pause for the value of **falling pause**.
|
||||
|
||||
```
|
||||
let basketX3 = 2
|
||||
let eggX3 = 2
|
||||
let eggY3 = 0
|
||||
let fallingPause1 = 300
|
||||
basic.forever(() => {
|
||||
led.unplot(basketX3, 4)
|
||||
led.unplot(eggX3, eggY3)
|
||||
eggY3 = eggY3 + 1
|
||||
led.plot(eggX3, eggY3)
|
||||
basic.pause(300)
|
||||
let accX3 = input.acceleration("x")
|
||||
basketX3 = 2 + Math.min(2, Math.max(-2, accX3 / 200))
|
||||
led.plot(basketX3, 4)
|
||||
if (eggY3 > 4) {
|
||||
eggY3 = -1
|
||||
eggX3 = Math.random(5)
|
||||
}
|
||||
if (eggY3 == 4) {
|
||||
if (basketX3 == eggX3) {
|
||||
game.addScore(1)
|
||||
if (math.mod(game.score(), 5) == 0) {
|
||||
fallingPause1 = fallingPause1 - 25 // ***
|
||||
}
|
||||
} else {
|
||||
game.removeLife(1)
|
||||
}
|
||||
}
|
||||
basic.pause(fallingPause1) // ***
|
||||
})
|
||||
```
|
||||
|
||||
Fantastic! Your game is now ready to show off.
|
||||
|
||||
* Press the `run` button to see your finished game!
|
61
docs/reference/js/lessons/catch-the-egg-game/quiz-answers.md
Normal file
61
docs/reference/js/lessons/catch-the-egg-game/quiz-answers.md
Normal file
@ -0,0 +1,61 @@
|
||||
# catch the egg game quiz answers
|
||||
|
||||
Programming a game of catch the egg using the accelerometer
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [catch the egg tutorial](/microbit/lessons/catch-the-egg-game/tutorial)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Write the data type for the global variables 'basket' and 'egg'.
|
||||
|
||||
<br/>
|
||||
|
||||
'Basket' and 'egg' are stored as **Number**.
|
||||
|
||||
## 2. Write the code to plot the initial position of the egg and the basket using the variables 'egg x', 'egg y', and 'basket x'. The code should arrange the egg and basket as shown below.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
led.plot(eggX, eggY)
|
||||
led.plot(basketX, 4)
|
||||
```
|
||||
|
||||
## 3. Write the three lines of code that moves the egg down. (You need to unplot the egg's current position, update its position variables, and plot its new position.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
led.unplot(eggX, eggY)
|
||||
eggY = eggY + 1
|
||||
led.plot(eggX, eggY)
|
||||
```
|
||||
|
||||
## 4. Write the code that calculates 'basket x' given the variable 'acc x'.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
let accX = input.acceleration("x")
|
||||
basketX = 2 + Math.min(2, Math.max(-2, accX / 200))
|
||||
```
|
||||
|
||||
Note: the first line of code in this answer is optional.
|
||||
|
||||
## 5. Write the code that resets the egg after it has fallen past the bottom of the BBC micro:bit.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
if (eggY > 4) {
|
||||
eggY = -1
|
||||
eggX = Math.random(5)
|
||||
}
|
||||
```
|
||||
|
34
docs/reference/js/lessons/catch-the-egg-game/quiz.md
Normal file
34
docs/reference/js/lessons/catch-the-egg-game/quiz.md
Normal file
@ -0,0 +1,34 @@
|
||||
# catch the egg game quiz
|
||||
|
||||
Programming a game of catch the egg using the accelerometer.
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [catch the egg tutorial](/microbit/lessons/catch-the-egg-game/tutorial)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Write the data type for the global variables 'basket' and 'egg'.
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Write the code to plot the initial position of the egg and the basket using the variables 'egg x', 'egg y', and 'basket x'. The code should arrange the egg and basket as shown below.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Write the three lines of code that moves the egg down. (You need to unplot the egg's current position, update its position variables, and plot its new position.
|
||||
|
||||
<br/>
|
||||
|
||||
## 4. Write the code that calculates 'basket x' given the variable 'acc x'.
|
||||
|
||||
<br/>
|
||||
|
||||
## 5. Write the code that resets the egg after it has fallen past the bottom of the BBC micro:bit.
|
||||
|
||||
<br/>
|
||||
|
8
docs/reference/js/lessons/catch-the-egg.md
Normal file
8
docs/reference/js/lessons/catch-the-egg.md
Normal file
@ -0,0 +1,8 @@
|
||||
# catch the egg
|
||||
|
||||
Programming a game of 'catch the egg' using the accelerometer in Touch Develop #docs #functions #var
|
||||
|
||||
Programming a game of 'catch the egg' using the accelerometer
|
||||
|
||||
* [tutorial](/microbit/lessons/catch-the-egg-game/tutorial)
|
||||
* [challenges](/microbit/lessons/catch-the-egg/challenges)
|
77
docs/reference/js/lessons/clear-screen/challenges.md
Normal file
77
docs/reference/js/lessons/clear-screen/challenges.md
Normal file
@ -0,0 +1,77 @@
|
||||
# clear screen challenges
|
||||
|
||||
My script. #docs
|
||||
|
||||
### Challenge 0
|
||||
|
||||
Welcome! This [guided tutorial](/microbit/hzckbb) will help you create the script to clear the screen!
|
||||
|
||||
Your goal is to clear the screen after displaying an animation. Begin by showing and displaying an animation. Remember that the `show animation` is in the `basic` namespace. We then need to detect when the "A" button is pressed. Finally, clear the screen by typing in `basic->clear screen`.
|
||||
|
||||
Your main function should look like this:
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
. . . . . # # # # # # # # # # . . . . .
|
||||
. . . . . # # # # # # # # # # # # # # #
|
||||
. . . . . . . . . . . . . . . # # # # #
|
||||
`, 400)
|
||||
input.onButtonPressed("A", () => {
|
||||
basic.clearScreen()
|
||||
})
|
||||
```
|
||||
|
||||
* tap the `run` button to view the script on the monitor.
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Create an event handler for Button "B".
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
. . . . . # # # # # # # # # # . . . . .
|
||||
. . . . . # # # # # # # # # # # # # # #
|
||||
. . . . . . . . . . . . . . . # # # # #
|
||||
`, 400)
|
||||
input.onButtonPressed("A", () => {
|
||||
basic.clearScreen()
|
||||
})
|
||||
input.onButtonPressed("B", () => {
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Replay the animation when the "B" button is pressed by typing in `basic->show animation(..., 400)`.
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
. . . . . # # # # # # # # # # . . . . .
|
||||
. . . . . # # # # # # # # # # # # # # #
|
||||
. . . . . . . . . . . . . . . # # # # #
|
||||
`, 400)
|
||||
input.onButtonPressed("A", () => {
|
||||
basic.clearScreen()
|
||||
})
|
||||
input.onButtonPressed("B", () => {
|
||||
basic.showAnimation(`
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
# # # # # # # # # # . . . . . . . . . .
|
||||
. . . . . # # # # # # # # # # . . . . .
|
||||
. . . . . # # # # # # # # # # # # # # #
|
||||
. . . . . . . . . . . . . . . # # # # #
|
||||
`, 400) // ***
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Show an animation that scrolls back up when you press button "B".
|
||||
|
||||
* tap the `run` button to view your final product!
|
128
docs/reference/js/lessons/column/quiz.md
Normal file
128
docs/reference/js/lessons/column/quiz.md
Normal file
@ -0,0 +1,128 @@
|
||||
# cascade 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 [light column cascade tutorial](/microbit/js/light-column-cascade/tutorial).
|
||||
|
||||
Answer the questions below while working on or after you finish the tutorial. Pay attention to the dialogs!
|
||||
|
||||
## 1. What is a for loop?
|
||||
|
||||
## 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 all the locations where the LED is lighted. Explain why the LED is lighted there.
|
||||
|
||||

|
||||
|
||||
## 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 all the locations where the LED is lighted. Explain why the LED is lighted there.
|
||||
|
||||

|
||||
|
||||
## 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.
|
||||
|
||||

|
||||
|
||||
******************************
|
||||
|
||||
## KEY
|
||||
|
||||
## Directions
|
||||
|
||||
Answer the questions below while working on or after you finish the tutorial.
|
||||
|
||||
## 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 i3 = 0; i3 < 5; i3++) {
|
||||
for (let j3 = 0; j3 < 5; j3++) {
|
||||
led.plot(i3, j3)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
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 i4 = 0; i4 < 3; i4++) {
|
||||
for (let j4 = 0; j4 < 3; j4++) {
|
||||
led.plot(i4, j4)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
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 i5 = 0; i5 < 1; i5++) {
|
||||
for (let j5 = 0; j5 < 1; j5++) {
|
||||
led.plot(i5, j5)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
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)
|
||||
|
79
docs/reference/js/lessons/compare-machine/challenges.md
Normal file
79
docs/reference/js/lessons/compare-machine/challenges.md
Normal file
@ -0,0 +1,79 @@
|
||||
# compare machine challenges
|
||||
|
||||
These challenges allow you to set the value of a counter to 1 when button B is pressed. #docs
|
||||
|
||||
### Challenge 0
|
||||
|
||||
Welcome! This [guided tutorial](/microbit/lessons/comparison/tutorial) will assist you with using the comparison operator.
|
||||
|
||||
```
|
||||
counter = 0
|
||||
input.onButtonPressed("A", () => {
|
||||
counter = counter + 1
|
||||
if (counter == 10) {
|
||||
counter = 1
|
||||
}
|
||||
basic.showNumber(counter, 150)
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Now let's do something special when the micro:bit reaches the number `5`. Instead of just showing the number `5`, let's show the string `HALF WAY!`. Begin by setting an if statement to know when `counter = 5`.
|
||||
|
||||
```
|
||||
counter = 0
|
||||
input.onButtonPressed("A", () => {
|
||||
counter = counter + 1
|
||||
if (counter == 10) {
|
||||
counter = 1
|
||||
}
|
||||
if (counter == 5) {
|
||||
}
|
||||
basic.showNumber(counter, 150)
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Let's continue our plan of displaying `HALF WAY!` when `counter = 5`. To do so, add the following line of code inside the if statement.
|
||||
|
||||
```
|
||||
counter = 0
|
||||
input.onButtonPressed("A", () => {
|
||||
counter = counter + 1
|
||||
if (counter == 10) {
|
||||
counter = 1
|
||||
}
|
||||
if (counter == 5) {
|
||||
basic.showString("HALF WAY!", 150) // ***
|
||||
}
|
||||
basic.showNumber(counter, 150)
|
||||
})
|
||||
```
|
||||
|
||||
* Run your code to see if it works as expected.
|
||||
|
||||
### Challenge 3
|
||||
|
||||
You may notice a problem right now. When `counter = 5`, the micro:bit will show both the message `HALF WAY!` and the number `5`. In order to fix this problem, let's take advantage of the `else` at the end of the if statement.
|
||||
|
||||
```
|
||||
counter = 0
|
||||
input.onButtonPressed("A", () => {
|
||||
counter = counter + 1
|
||||
if (counter == 10) {
|
||||
counter = 1
|
||||
}
|
||||
if (counter == 5) {
|
||||
basic.showString("HALF WAY!", 150)
|
||||
} else {
|
||||
basic.showNumber(counter, 150) // ***
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 4
|
||||
|
||||
When `counter = 8`, display the message `ALMOST THERE!` on the micro:bit. You will need to add an `else if` after the if statement of `counter = 5`.
|
||||
|
8
docs/reference/js/lessons/compass.md
Normal file
8
docs/reference/js/lessons/compass.md
Normal file
@ -0,0 +1,8 @@
|
||||
# compass lesson
|
||||
|
||||
build a compass app that applies the BBC micro:bit magnetic sensor (magnetometer) #functions #var #docs
|
||||
|
||||
build a compass app that applies the BBC micro:bit magnetic sensor (magnetometer)
|
||||
|
||||
* [tutorial](/microbit/lessons/compass/tutorial)
|
||||
* [challenges](/microbit/lessons/compass/challenges)
|
88
docs/reference/js/lessons/compass/challenges.md
Normal file
88
docs/reference/js/lessons/compass/challenges.md
Normal file
@ -0,0 +1,88 @@
|
||||
# compass challenges
|
||||
|
||||
Display the direction that the BBC micro:bit is facing using the compass
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following guided tutorial:
|
||||
|
||||
* [tutorial](/microbit/lessons/compass/tutorial)
|
||||
|
||||
At the end of the tutorial, click `keep editing`. Your code should look like this:
|
||||
|
||||
```
|
||||
input.calibrate()
|
||||
basic.forever(() => {
|
||||
let degrees = input.compassHeading()
|
||||
if (degrees < 45) {
|
||||
basic.showString("N", 100)
|
||||
} else if (degrees < 135) {
|
||||
basic.showString("E", 100)
|
||||
}
|
||||
else if (degrees < 225) {
|
||||
basic.showString("S", 100)
|
||||
}
|
||||
else {
|
||||
basic.showString("W", 100)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Instead of displaying `N` when the BBC micro:bit is pointing North, display a star to indicate the north star.
|
||||
|
||||
```
|
||||
input.calibrate()
|
||||
basic.forever(() => {
|
||||
let degrees1 = input.compassHeading()
|
||||
if (degrees1 < 45) {
|
||||
basic.plotImage(`
|
||||
# . # . #
|
||||
. # # # .
|
||||
# # # # #
|
||||
. # # # .
|
||||
# . # . #
|
||||
`) // ***
|
||||
} else if (degrees1 < 135) {
|
||||
basic.showString("E", 100)
|
||||
}
|
||||
else if (degrees1 < 225) {
|
||||
basic.showString("S", 100)
|
||||
}
|
||||
else {
|
||||
basic.showString("W", 100)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
* Run your code to see if it works as expected
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Instead of displaying just `N`, `W`, `S`, or `E`, display the full word.
|
||||
|
||||
```
|
||||
input.calibrate()
|
||||
basic.forever(() => {
|
||||
let degrees2 = input.compassHeading()
|
||||
if (degrees2 < 45) {
|
||||
basic.showString("NORTH", 100) // ***
|
||||
} else if (degrees2 < 135) {
|
||||
basic.showString("EAST", 100) // ***
|
||||
}
|
||||
else if (degrees2 < 225) {
|
||||
basic.showString("SOUTH", 100) // ***
|
||||
}
|
||||
else {
|
||||
basic.showString("WEST", 100) // ***
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
* Run your code to see if it works as expected
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Display your own unique message for each direction.
|
||||
|
56
docs/reference/js/lessons/compass/quiz-answers.md
Normal file
56
docs/reference/js/lessons/compass/quiz-answers.md
Normal file
@ -0,0 +1,56 @@
|
||||
# compass quiz answers
|
||||
|
||||
Create an actual compass to show your direction: North, South, East, or West
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [compass tutorial](/microbit/lessons/compass/tutorial).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. What is the purpose of the 'compass heading' block?
|
||||
|
||||
Gets the compass heading of the BBC micro:bit in degrees
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Write the code that stores the compass heading into a local variable called 'degrees'.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
let degrees = input.compassHeading()
|
||||
```
|
||||
|
||||
## 3. Write the 'If statement' that will check if the device is mostly pointing North. Display 'N' on the BBC micro:bit
|
||||
|
||||
<br />
|
||||
|
||||
```
|
||||
if (degrees < 45) {
|
||||
basic.showString("N", 150)
|
||||
}
|
||||
```
|
||||
|
||||
## 3. Write the 'If statement' that will check if the device is mostly pointing East. Display 'E' on the BBC micro:bit
|
||||
|
||||
<br />
|
||||
|
||||
```
|
||||
if (degrees < 135) {
|
||||
basic.showString("E", 150)
|
||||
}
|
||||
```
|
||||
|
||||
## 3. Write the 'If statement' that will check if the device is mostly pointing South. Display 'S' on the BBC micro:bit
|
||||
|
||||
<br />
|
||||
|
||||
```
|
||||
if (degrees < 225) {
|
||||
basic.showString("S", 150)
|
||||
}
|
||||
```
|
||||
|
32
docs/reference/js/lessons/compass/quiz.md
Normal file
32
docs/reference/js/lessons/compass/quiz.md
Normal file
@ -0,0 +1,32 @@
|
||||
# compass quiz
|
||||
|
||||
Create an actual compass to show your direction: North, South, East, or West
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [compass tutorial](/microbit/lessons/compass/tutorial).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. What is the purpose of the 'compass heading' block?
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Write the code that stores the compass heading into a local variable called 'degrees'.
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Write the 'If statement' that will check if the device is mostly pointing North. Display 'N' on the BBC micro:bit
|
||||
|
||||
<br />
|
||||
|
||||
## 3. Write the 'If statement' that will check if the device is mostly pointing East. Display 'E' on the BBC micro:bit
|
||||
|
||||
<br />
|
||||
|
||||
## 3. Write the 'If statement' that will check if the device is mostly pointing South. Display 'S' on the BBC micro:bit
|
||||
|
||||
<br />
|
||||
|
80
docs/reference/js/lessons/counter.md
Normal file
80
docs/reference/js/lessons/counter.md
Normal file
@ -0,0 +1,80 @@
|
||||
# counter lesson
|
||||
|
||||
Learn how to create a counter with with on button pressed. #show #number #screen #number #math #docs
|
||||
|
||||
### @video td/videos/counter-0
|
||||
|
||||
## Topic
|
||||
|
||||
Variables
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [activity](/microbit/lessons/counter/activity)
|
||||
* [challenges](/microbit/lessons/counter/challenges)
|
||||
* [quiz](/microbit/lessons/counter/quiz)
|
||||
* [quiz answers](/microbit/lessons/counter/quiz-answers)
|
||||
* [tutorial](/microbit/lessons/counter/tutorial)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to creating a **variable** to keep track of the current count. We will be learning how to create a counter app using a variable as well as simple commands, such as on button pressed, and show number.
|
||||
|
||||
## Documentation
|
||||
|
||||
* **variable**: [read more...](/microbit/reference/variables/var)
|
||||
* **arithmetic operators**: [read more...](/microbit/reference/types/number)
|
||||
* **on button pressed** : [read more...](/microbit/reference/input/on-button-pressed)
|
||||
* **show number** : [read more...](/microbit/reference/basic/show-number)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to create a variable as a place where you can store data so that you can use it later in your code, accessible across all functions, and in nested code blocks
|
||||
* learn how arithmetic operators operate on numbers and return a number
|
||||
* learn how to run code when an input button is pressed
|
||||
* learn how to show a number on the LED screen, one digit at a time (scrolling from left to right)
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* 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)
|
||||
* Declares and assigns variables.(AB)
|
||||
|
||||
#### 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: 20 min.
|
||||
* [activity](/microbit/lessons/counter/activity)
|
||||
* [tutorial](/microbit/lessons/counter/tutorial)
|
||||
* [quiz](/microbit/lessons/counter/quiz)
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/counter/challenges)
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/counter/challenges)
|
||||
|
45
docs/reference/js/lessons/counter/activity.md
Normal file
45
docs/reference/js/lessons/counter/activity.md
Normal file
@ -0,0 +1,45 @@
|
||||
# counter activity
|
||||
|
||||
Display a number with a variable.
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
### @video td/videos/counter-0
|
||||
|
||||
Welcome! This tutorial will teach you how to make a counter that increments when button A is pressed. Let's get started!
|
||||
|
||||
### ~
|
||||
|
||||
To create a new script, go to the [Create Code](/microbit/create-code) page and tap *New Project* under **Touch Develop**.
|
||||
|
||||
Let's start by creating a **local variable** `count` to keep track of the current count.
|
||||
|
||||
```
|
||||
let count = 0
|
||||
```
|
||||
|
||||
The code under ``on button pressed("A")`` will run each time the user presses A. Let's add a line of code that increments `count` by `1`.
|
||||
|
||||
```
|
||||
let count_ = 0
|
||||
input.onButtonPressed("A", () => {
|
||||
count = count + 1
|
||||
})
|
||||
```
|
||||
|
||||
Since the count has changed, it's time to refresh the screen display. Let's add a line of code to display the count on screen.
|
||||
|
||||
```
|
||||
let count_1 = 0
|
||||
input.onButtonPressed("A", () => {
|
||||
count = count + 1
|
||||
basic.showNumber(count, 150)
|
||||
})
|
||||
```
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/microbit/lessons/counter/challenges)!
|
||||
|
||||
### ~
|
||||
|
38
docs/reference/js/lessons/counter/challenges.md
Normal file
38
docs/reference/js/lessons/counter/challenges.md
Normal file
@ -0,0 +1,38 @@
|
||||
# counter challenges
|
||||
|
||||
Coding challenges for the counter tutorial.
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following [guided tutorial](/microbit/lessons/counter/activity) At the end of the tutorial, your code should look like this:
|
||||
|
||||
```
|
||||
let count = 0
|
||||
input.onButtonPressed("A", () => {
|
||||
count = count + 1
|
||||
basic.showNumber(count, 150)
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
### @video td/videos/counter-1-2
|
||||
|
||||
Let's add the code to `count` when `B` is pressed. Add an event handler with `input->on button pressed(B)` then add the code to `count`.
|
||||
|
||||
```
|
||||
let count1 = 0
|
||||
input.onButtonPressed("A", () => {
|
||||
count1 = count1 + 1
|
||||
basic.showNumber(count1, 150)
|
||||
})
|
||||
input.onButtonPressed("B", () => {
|
||||
count1 = count1 - 1 // ***
|
||||
basic.showNumber(count1, 150) // ***
|
||||
}) // ***
|
||||
```
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Now let's try to reset the counter when the BBC micro:bit is shaken. You will need to register an event handler with `input->on shake`.
|
||||
|
91
docs/reference/js/lessons/counter/lesson-plan.md
Normal file
91
docs/reference/js/lessons/counter/lesson-plan.md
Normal file
@ -0,0 +1,91 @@
|
||||
# counter lesson plan
|
||||
|
||||
Learn how to create a counter with with on button pressed.
|
||||
|
||||
### @video vimeo/134118661
|
||||
|
||||
## Topic
|
||||
|
||||
Variable - Counter
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to creating a **variable** to keep track of the current count. We will be learning how to create a counter app using global variables as well as simple commands, such as on button pressed, and show number.
|
||||
|
||||
## 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 Forever. Forever will repeats code in the background forever.
|
||||
|
||||
**Command:** An instruction for the computer to execute, written in a particular programming language.**
|
||||
|
||||
**QuickStart Computing Glossary
|
||||
|
||||
## Documentation
|
||||
|
||||
* **variables**: [read more...](/microbit/reference/variables/var)
|
||||
* **on button pressed** : [read more...](/microbit/reference/input/on-button-pressed)
|
||||
* **show number** : [read more...](/microbit/reference/basic/show-number)
|
||||
|
||||
## Resources
|
||||
|
||||
* Activity: [tutorial](/microbit/lessons/counter/tutorial)
|
||||
* Activity: [quiz](/microbit/lessons/counter/quiz)
|
||||
* Extended Activity: [challenges](/microbit/lessons/counter/challenges)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to create a variable
|
||||
* learn how to blink a light
|
||||
* learn how to repeat turning on and off the light
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* 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)
|
||||
* Declares and assigns variables.(AB)
|
||||
|
||||
#### 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: 20 min.
|
||||
* [tutorial](/microbit/lessons/counter/tutorial)
|
||||
* [quiz](/microbit/lessons/counter/quiz)
|
||||
* assessment opportunities: forever, plot, pause, clear screen
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/counter/challenges)
|
||||
* assessment opportunities: loops, plot, pause, clear screen
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/counter/challenges)
|
||||
|
||||
## Intended follow on
|
||||
|
||||
Publish script to the classroom.
|
||||
|
54
docs/reference/js/lessons/counter/quiz-answers.md
Normal file
54
docs/reference/js/lessons/counter/quiz-answers.md
Normal file
@ -0,0 +1,54 @@
|
||||
# counter quiz answers
|
||||
|
||||
Learn how to create a counter with the BBC micro:bit button.
|
||||
|
||||
This is the answer key for the [counter quiz](/microbit/lessons/counter/quiz).
|
||||
|
||||
## 1. What is a variable?
|
||||
|
||||
Answers may vary but a variable is a place where you can store and retrieve data
|
||||
|
||||
## 2. Draw the stored value for the variable called count
|
||||
|
||||
```
|
||||
let count = 0
|
||||
```
|
||||
|
||||

|
||||
|
||||
We create a **variable**, `count` to keep track of the current count. The number 0 is stored into memory of the variable.
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Draw which LEDs are ON after running this code and pressing button "A" once. Explain you chose to draw that number
|
||||
|
||||
```
|
||||
let count_ = 0
|
||||
input.onButtonPressed("A", () => {
|
||||
count_ = count_ + 1
|
||||
basic.showNumber(count, 150)
|
||||
})
|
||||
```
|
||||
|
||||

|
||||
|
||||
We are only pressing on button pressed once. So the number to display on the micro:bit is also one.
|
||||
|
||||
<br/>
|
||||
|
||||
## 4. Draw which LEDs are ON after running this code and pressing button "A" three times. Explain you chose to draw that number
|
||||
|
||||
```
|
||||
count_ = 0
|
||||
input.onButtonPressed("A", () => {
|
||||
count_ = count_ + 1
|
||||
basic.showNumber(count_, 100)
|
||||
})
|
||||
```
|
||||
|
||||

|
||||
|
||||
We included the code ``on button pressed("A")`` that runs each time the user presses A. The code increments `count` by `1`. We increase `count` by 1 whenever the user presses the button. So the third time the A button is pressed on the BBC micro:bit, the number 3 is displayed
|
||||
|
||||
<br/>
|
||||
|
54
docs/reference/js/lessons/counter/quiz.md
Normal file
54
docs/reference/js/lessons/counter/quiz.md
Normal file
@ -0,0 +1,54 @@
|
||||
# counter quiz
|
||||
|
||||
Learn how to create a counter with the BBC micro:bit button.
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [counter tutorial](/microbit/lessons/counter/activity).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. What is a variable?
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Draw the stored value for the variable called count
|
||||
|
||||
```
|
||||
let count = 0
|
||||
```
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Draw which LEDs are ON after running this code and pressing button "A" once. Explain you chose to draw that number
|
||||
|
||||
```
|
||||
let count_ = 0
|
||||
input.onButtonPressed("A", () => {
|
||||
count_ = count_ + 1
|
||||
basic.showNumber(count_, 100)
|
||||
})
|
||||
```
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
## 4. Draw which LEDs are ON after running this code and pressing button "A" three times. Explain you chose to draw that number
|
||||
|
||||
```
|
||||
count_ = 0
|
||||
input.onButtonPressed("A", () => {
|
||||
count_ = count_ + 1
|
||||
basic.showNumber(count_, 100)
|
||||
})
|
||||
```
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
91
docs/reference/js/lessons/die-roll.md
Normal file
91
docs/reference/js/lessons/die-roll.md
Normal file
@ -0,0 +1,91 @@
|
||||
# die roll lesson
|
||||
|
||||
create a die on the BBC micro:bit #button #pressed #math #random #var #string #if #docs
|
||||
|
||||
## Topic
|
||||
|
||||
If (Conditionals)
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [activity](/microbit/lessons/die-roll/activity)
|
||||
* [challenges](/microbit/lessons/die-roll/challenges)
|
||||
* [quiz](/microbit/lessons/die-roll/quiz)
|
||||
* [quiz answers](/microbit/lessons/die-roll/quiz-answers)
|
||||
* [tutorial](/microbit/lessons/die-roll/tutorial)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to use an if statements to run code run code depending on whether a condition is true or not. We will be learning how to create a die with If statements, On Shake, Variables, Assignment Operator, Pick Random and Show LEDs
|
||||
|
||||
## Documentation
|
||||
|
||||
* **Variables** : [read more...](/microbit/reference/variables/var)
|
||||
* **If** : [read more...](/microbit/reference/logic/if)
|
||||
* **On Shake** : [read more...](/microbit/reference/input/on-gesture)
|
||||
* **Assignment Operator** : [read more...](/microbit/reference/variables/assign)
|
||||
* **Math Random** : [read more...](/microbit/js/math)
|
||||
* **Show LEDs** : [read more...](/microbit/reference/basic/show-leds)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to run code when the BBC micro:bit is shaken, when running code in the web browser, moving the mouse quickly simulates shaking
|
||||
* learn how to create a local variable as a place where you can store and retrieve data
|
||||
* learn how the assignment operator is used to declare a new local variable
|
||||
* learn how to declare a new local variable or update the value of a variable
|
||||
* learn how to return a random number
|
||||
* learn how to conditionally run code depending on whether a condition is true or not
|
||||
* learn how to show an image on the LED screen
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* Designs solutions (algorithms) that use repetition and two-way selection, ie if, then and else.(AL)
|
||||
* Uses diagrams to express solutions.(AB)
|
||||
* Uses logical reasoning to predict outputs, showing an awareness of inputs (AL)
|
||||
* Designs solutions by decomposing a problem and creates a sub-solution for each of these parts. (DE) (AL) (AB)
|
||||
* Represents solutions using a structured notation (AL) (AB)
|
||||
|
||||
#### Programming & Development
|
||||
|
||||
* Creates programs that implement algorithms to achieve given goals (AL)
|
||||
* Declares and assigns variables(AB)
|
||||
* Understands the difference between, and appropriately uses if and if, then and else statements(AL)
|
||||
* Uses a range of operators and expressions e.g. Boolean, and applies them in the context of program control. (AL)
|
||||
* Selects the appropriate data types(AL) (AB
|
||||
|
||||
#### Data & Data Representation
|
||||
|
||||
* Understands the difference between data and information(AB)
|
||||
* Uses filters or can perform single criteria searches for information.(AL)
|
||||
* Performs more complex searches for information e.g. using Boolean and relational operators(AL) (GE) (EV)
|
||||
* Defines data types: real numbers and Boolean (AB)
|
||||
|
||||
#### Hardware & Processing
|
||||
|
||||
* Knows that computers collect data from various input devices, including sensors and application software (AB)
|
||||
* Demonstrates responsible use of technologies and online services, and knows a range of ways to report concerns Understands how search engines rank search results (AL)
|
||||
|
||||
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation
|
||||
|
||||
## Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [activity](/microbit/lessons/die-roll/activity)
|
||||
* [tutorial](/microbit/lessons/die-roll/tutorial)
|
||||
* [quiz](/microbit/lessons/die-roll/quiz)
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/die-roll/challenges)
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/die-roll/challenges)
|
||||
|
130
docs/reference/js/lessons/die-roll/activity.md
Normal file
130
docs/reference/js/lessons/die-roll/activity.md
Normal file
@ -0,0 +1,130 @@
|
||||
# die roll activity
|
||||
|
||||
Create a die on the BBC micro:bit
|
||||
|
||||
To create a new script, go to the [Create Code](/microbit/create-code) page and tap *New Project* under **KindScript**.
|
||||
|
||||
Let's create a condition for when the BBC micro:bit is shaken.
|
||||
|
||||
```
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
})
|
||||
```
|
||||
|
||||
We need to show a random value from 1 to 6 on our die. So let's make a local variable called **roll**.
|
||||
|
||||
```
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let roll = Math.random(6)
|
||||
})
|
||||
```
|
||||
|
||||
We need a condition for if **roll** is 5. We will show a `6` if **roll** is 5 because **roll** has a range from 0 to 5. We can use `Show LEDs` to display the side of a die that shows 6.
|
||||
|
||||
```
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let roll1 = Math.random(6)
|
||||
if (roll1 == 5) {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
`, 400)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
Let's use an `else if` condition for if **roll** is 4. If **roll** is 4 we can show 5 dots on the die.
|
||||
|
||||
```
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let roll2 = Math.random(6)
|
||||
if (roll2 == 5) {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
`, 400)
|
||||
} else if (roll2 == 4) {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . # . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
`, 400)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
Now we need to repeat the same steps for if **roll** is 3. If **roll** is 3 we will show `4` on the die. Let's also repeat these steps to show the 3, 2, and 1 on the die. We are almost done with our die!
|
||||
|
||||
```
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let roll3 = Math.random(6)
|
||||
if (roll3 == 5) {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
`, 400)
|
||||
} else if (roll3 == 4) {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . # . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
`, 400)
|
||||
}
|
||||
else if (roll3 == 3) {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
`, 400)
|
||||
}
|
||||
else if (roll3 == 2) {
|
||||
basic.showLeds(`
|
||||
# . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . #
|
||||
`, 400)
|
||||
}
|
||||
else if (roll3 == 1) {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . . .
|
||||
. . . . .
|
||||
. . . # .
|
||||
. . . . .
|
||||
`, 400)
|
||||
}
|
||||
else {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`, 400)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/microbit/lessons/die-roll/challenges)!
|
||||
|
||||
### ~
|
||||
|
201
docs/reference/js/lessons/die-roll/challenges.md
Normal file
201
docs/reference/js/lessons/die-roll/challenges.md
Normal file
@ -0,0 +1,201 @@
|
||||
# die roll challenges
|
||||
|
||||
Create a die on the BBC micro:bit.
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following guided tutorial:
|
||||
|
||||
* [tutorial](/microbit/lessons/die-roll/tutorial)
|
||||
|
||||
At the end of the tutorial, click `keep editing`. Your code should look like this:
|
||||
|
||||
```
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let roll = Math.random(6) // ***
|
||||
if (roll == 5) {
|
||||
basic.plotImage(`
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
`)
|
||||
} else if (roll == 4) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . # . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
else if (roll == 3) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
else if (roll == 2) {
|
||||
basic.plotImage(`
|
||||
# . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . #
|
||||
`)
|
||||
}
|
||||
else if (roll == 1) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. # . . .
|
||||
. . . . .
|
||||
. . . # .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
else {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Modify the line of code with `math->random` so that only number 1-4 can appear on the die.
|
||||
|
||||
```
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let roll1 = Math.random(4) // ***
|
||||
if (roll1 == 5) {
|
||||
basic.plotImage(`
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
`)
|
||||
} else if (roll1 == 4) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . # . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
else if (roll1 == 3) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
else if (roll1 == 2) {
|
||||
basic.plotImage(`
|
||||
# . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . #
|
||||
`)
|
||||
}
|
||||
else if (roll1 == 1) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. # . . .
|
||||
. . . . .
|
||||
. . . # .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
else {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Let's make a trick die! Modify the line of code with `math->random` so that only numbers 3-6 can appear on the die. Also note that we need to ensure `roll = 0` when only 1 dot is shown on the BBC micro:bit.
|
||||
|
||||
```
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let roll2 = Math.random(4) + 2 // ***
|
||||
if (roll2 == 5) {
|
||||
basic.plotImage(`
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
`)
|
||||
} else if (roll2 == 4) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . # . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
else if (roll2 == 3) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
else if (roll2 == 2) {
|
||||
basic.plotImage(`
|
||||
# . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . #
|
||||
`)
|
||||
}
|
||||
else if (roll2 == 1) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. # . . .
|
||||
. . . . .
|
||||
. . . # .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
else if (roll2 == 0) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Add a couple more conditions so that the BBC micro:bit randomly chooses a number between 1 and 8.
|
||||
|
116
docs/reference/js/lessons/die-roll/quiz-answers.md
Normal file
116
docs/reference/js/lessons/die-roll/quiz-answers.md
Normal file
@ -0,0 +1,116 @@
|
||||
# die roll quiz answers
|
||||
|
||||
Create a die when the BBC micro:bit is shaken
|
||||
|
||||
These are the answers to the [die roll quiz](/microbit/lessons/die-roll/quiz).
|
||||
|
||||
## 1. Create a variable named 'roll' that will be randomly assigned to a number between 0 and 5.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
let roll = Math.random(6)
|
||||
```
|
||||
|
||||
## 2. If the variable "roll" equals 5, write the code that will plot the image below
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
if (roll == 5) {
|
||||
basic.plotImage(`
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
`)
|
||||
}
|
||||
```
|
||||
|
||||
## 3. You will use an `else if` condition if "roll" is equal 4. Write the `else if` statement that will display the plot image below
|
||||
|
||||

|
||||
|
||||
<br />
|
||||
|
||||
```
|
||||
if (roll == 5) {
|
||||
basic.plotImage(`
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
`)
|
||||
} else if (roll == 4) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . # . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
```
|
||||
|
||||
Note: students are only required to write the bottom half of this answer, starting with "else if".
|
||||
|
||||
## 4. You will use an `else if` condition if "roll" is equal 3. Write the `else if` statement that will display the plot image below
|
||||
|
||||

|
||||
|
||||
<br />
|
||||
|
||||
```
|
||||
if (roll == 4) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . # . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
`)
|
||||
} else if (roll == 3) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
```
|
||||
|
||||
Note: students are only required to write the bottom half of this answer, starting with "else if".
|
||||
|
||||
## 5. You will use an `else if` condition if "roll" is equal 2. Write the `else if` that will display the image below
|
||||
|
||||

|
||||
|
||||
<br />
|
||||
|
||||
```
|
||||
if (roll == 3) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
`)
|
||||
} else if (roll == 2) {
|
||||
basic.plotImage(`
|
||||
# . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . #
|
||||
`)
|
||||
}
|
||||
```
|
||||
|
||||
Note: students are only required to write the bottom half of this answer, starting with "else if".
|
||||
|
42
docs/reference/js/lessons/die-roll/quiz.md
Normal file
42
docs/reference/js/lessons/die-roll/quiz.md
Normal file
@ -0,0 +1,42 @@
|
||||
# die roll quiz
|
||||
|
||||
Create a die when the BBC micro:bit is shaken
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [die roll tutorial](/microbit/lessons/die-roll/tutorial).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Create a variable named 'roll' that will be randomly assigned to a number between 0 and 5.
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. If the variable "roll" equals 5, write the code that will plot the image below
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
## 3. You will use an `else if` condition if "roll" is equal 4. Write the `else if` statement that will display the plot image below
|
||||
|
||||

|
||||
|
||||
<br />
|
||||
|
||||
<br/>
|
||||
|
||||
## 4. You will use an `else if` condition if "roll" is equal 3. Write the `else if` statement that will display the plot image below
|
||||
|
||||

|
||||
|
||||
<br />
|
||||
|
||||
## 5. You will use an `else if` condition if "roll" is equal 2. Write the `else if` that will display the image below
|
||||
|
||||

|
||||
|
||||
<br />
|
||||
|
91
docs/reference/js/lessons/digi-yoyo.md
Normal file
91
docs/reference/js/lessons/digi-yoyo.md
Normal file
@ -0,0 +1,91 @@
|
||||
# digi yoyo lesson
|
||||
|
||||
create a counter with a while loop #while #loop #counter #docs
|
||||
|
||||
### @video td/videos/digi-yoyo-0
|
||||
|
||||
## Topic
|
||||
|
||||
While Loop
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [tutorial](/microbit/lessons/digi-yoyo/tutorial)
|
||||
* [quiz](/microbit/lessons/digi-yoyo/quiz)
|
||||
* [quiz answers](/microbit/lessons/digi-yoyo/quiz-answers)
|
||||
* [challenges](/microbit/lessons/digi-yoyo/challenges)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to creating a **while loop**, `while condition do` to repeat code while a condition is true. We will be learning how to create a digi yoyo app using a while loop, a variable, as well as basic commands, such as pause and show number.
|
||||
|
||||
## Documentation
|
||||
|
||||
* **local variables** : [read more...](/microbit/reference/variables/var)
|
||||
* **assignment operator** : [read more...](/microbit/reference/variables/assign)
|
||||
* **while loop** : [read more...](/microbit/js/while)
|
||||
* **relational operator ** : [read more...](/microbit/reference/types/number)
|
||||
* **pause** : [read more...](/microbit/reference/basic/pause)
|
||||
* **show number** : [read more...](/microbit/reference/basic/show-number)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to create a local variables to store data and use it in your code
|
||||
* learn how to set or change the value of a local variable
|
||||
* learn how to repeat code while a condition is true
|
||||
* learn how a relational comparison (<) of numbers will yield a Boolean
|
||||
* learn how to pause your code for the specified number of milliseconds
|
||||
* learn how to show a number on the LED screen
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* Uses diagrams to express solutions.(AB)
|
||||
* Recognises that different solutions exist for the same problem (AL) (AB) Understands that iteration is the repetition of a process such as a loop (AL)
|
||||
* Recognises that different algorithms exist for the same problem (AL) (GE)
|
||||
* Represents solutions using a structured notation (AL) (AB)
|
||||
* Can identify similarities and differences in situations and can use these to solve problems (pattern recognition)(GE)
|
||||
|
||||
#### Programming & Development
|
||||
|
||||
* Creates programs that implement algorithms to achieve given goals (AL)
|
||||
* Declares and assigns variables(AB)
|
||||
* Uses a variable and relational operators within a loop to govern termination (AL) (GE)
|
||||
* Selects the appropriate data types(AL) (AB
|
||||
|
||||
#### Data & Data Representation
|
||||
|
||||
* Uses filters or can perform single criteria searches for information.(AL)
|
||||
|
||||
#### Communication Networks
|
||||
|
||||
* Demonstrates responsible use of technologies and online services, and knows a range of ways to report concerns Understands how search engines rank search results (AL)
|
||||
|
||||
#### Information Technology
|
||||
|
||||
* Collects, organizes, 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)
|
||||
* Recognises ethical issues surrounding the application of information technology beyond school.
|
||||
|
||||
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation
|
||||
|
||||
## Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [tutorial](/microbit/lessons/digi-yoyo/tutorial)
|
||||
* [quiz](/microbit/lessons/digi-yoyo/quiz)
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/digi-yoyo/challenges)
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/digi-yoyo/challenges)
|
||||
|
65
docs/reference/js/lessons/digi-yoyo/challenges.md
Normal file
65
docs/reference/js/lessons/digi-yoyo/challenges.md
Normal file
@ -0,0 +1,65 @@
|
||||
# digi yoyo challenges
|
||||
|
||||
Coding challenges for the digi yoyo.
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following guided tutorial:
|
||||
|
||||
* [tutorial](/microbit/lessons/digi-yoyo/tutorial)
|
||||
|
||||
At the end of the tutorial, click `keep editing`. Your code should look like this:
|
||||
|
||||
```
|
||||
let count = 0
|
||||
while (count < 10) {
|
||||
basic.pause(1000)
|
||||
basic.showNumber(count, 150)
|
||||
count = count + 1
|
||||
}
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
How about we create a counter that counts backwards from 10 to 1? Let's add a while loop that executes only when `count` is greater than 0.
|
||||
|
||||
```
|
||||
let count1 = 0
|
||||
while (count1 < 10) {
|
||||
basic.pause(1000)
|
||||
basic.showNumber(count1, 150)
|
||||
count1 = count1 + 1
|
||||
}
|
||||
while (count1 > 0) {
|
||||
}
|
||||
```
|
||||
|
||||
### Challenge 2
|
||||
|
||||
### @video td/videos/digi-yoyo-1-2
|
||||
|
||||
Inside of the while loop, let's add `pause->(1000)` so that we have a pause between each number as it's counting down. Also, let's show `count`!
|
||||
|
||||
```
|
||||
let count2 = 0
|
||||
while (count2 < 10) {
|
||||
basic.pause(1000)
|
||||
basic.showNumber(count2, 150)
|
||||
count2 = count2 + 1
|
||||
}
|
||||
while (count2 > 0) {
|
||||
basic.pause(1000) // ***
|
||||
basic.showNumber(count2, 150) // ***
|
||||
}
|
||||
```
|
||||
|
||||
* Run the code to see if it works as expected.
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Now, we need `count` to decrease by one after the BBC micro:bit has displayed the value of `count`.
|
||||
|
||||
We can do this by adding this line:
|
||||
|
||||
`count := count - 1`
|
||||
|
34
docs/reference/js/lessons/digi-yoyo/quiz-answers.md
Normal file
34
docs/reference/js/lessons/digi-yoyo/quiz-answers.md
Normal file
@ -0,0 +1,34 @@
|
||||
# digi yoyo quiz answers
|
||||
|
||||
Answers for digi yoyo quiz.
|
||||
|
||||
This is the answer key for the [digi yoyo quiz](/microbit/lessons/digi-yoyo/quiz).
|
||||
|
||||
## 1. Describe what a "while loop" does?
|
||||
|
||||
<br/>
|
||||
|
||||
A loop that repeats code while a condition is true.
|
||||
|
||||
## 2. Write the code that will create a **variable** called `count` and set the variable to 0.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
let count = 0
|
||||
```
|
||||
|
||||
## 3. Create a `while loop` that will loop until the **variable** `count` equals 4.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
while (count < 5) {
|
||||
count = count + 1
|
||||
}
|
||||
```
|
||||
|
28
docs/reference/js/lessons/digi-yoyo/quiz.md
Normal file
28
docs/reference/js/lessons/digi-yoyo/quiz.md
Normal file
@ -0,0 +1,28 @@
|
||||
# digi yoyo quiz
|
||||
|
||||
Create a counter with a while loop
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [digi yoyo tutorial](/microbit/lessons/digi-yoyo/tutorial)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Describe what a "while loop" does?
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Write the code that will create a variable called count and set the variable to 0.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Write the code for a while loop that will loop until the variable count equals 4.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
133
docs/reference/js/lessons/digital-pet.md
Normal file
133
docs/reference/js/lessons/digital-pet.md
Normal file
@ -0,0 +1,133 @@
|
||||
# digital pet lesson
|
||||
|
||||
a display of pet images for the BBC micro:bit #functions #number #forever #button #string #pause #data #shake #docs
|
||||
|
||||
### @video td/videos/digital-pet-0
|
||||
|
||||
## Topic
|
||||
|
||||
Functions
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [tutorial](/microbit/lessons/digital-pet/tutorial)
|
||||
* [quiz](/microbit/lessons/digital-pet/quiz)
|
||||
* [quiz answers](/microbit/lessons/digital-pet/quiz-answers)
|
||||
* [challenges](/microbit/lessons/digital-pet/challenges)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to create **functions**, `function()` that perform a specific task and returns a result. We will be learning how to create a digital pet app using functions, global variables, forever loop, input button in pressed, input on shake as well as simple commands, such as show string, show number, and pause.
|
||||
|
||||
## What the teacher needs to know
|
||||
|
||||
* Algorithm: An unambiguous set of rules or a precise step-bystep guide to solve a problem or achieve a particular objective.
|
||||
* Command: An instruction for the computer to execute, written in a particular programming language.
|
||||
* Data: A structured set of numbers, possibly representing digitised text, images, sound or video, which can be processed or transmitted by a computer, also used for numerical (quantitative) information.
|
||||
* Hardware: The physical systems and components of digital devices; see also software.
|
||||
* Input: Data provided to a computer system, such as via a keyboard, mouse, microphone, camera or physical sensors.
|
||||
* Output: The information produced by a computer system for its user, typically on a screen, through speakers or on a printer, but possibly through the control of motors in physical systems.
|
||||
* Programmable toys: Robots designed for children to use, accepting input, storing short sequences of simple instructions and moving according to this stored program.
|
||||
* 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.
|
||||
* Script: A computer program typically executed one line at a time through an interpreter, such as the instructions for a Scratch character.
|
||||
* Selection: A programming construct in which one section of code or another is executed depending on whether a particular condition is met.
|
||||
* Sequence: To place program instructions in order, with each executed one after the other.
|
||||
* Simulation: Using a computer to model the state and behaviour of real-world (or imaginary) systems, including physical or social systems; an integral part of most computer games.
|
||||
* Variables: A way in which computer programs can store, retrieve or change data, such as a score, the time left, or the user’s name.
|
||||
|
||||
**QuickStart Computing Glossary
|
||||
|
||||
## Documentation
|
||||
|
||||
* **function** : [read more...](/microbit/js/function)
|
||||
* **call** : [read more...](/microbit/js/call)
|
||||
* **global variable** : [read more...](/microbit/js/data)
|
||||
* **assignment operator** : [read more...](/microbit/reference/variables/assign)
|
||||
* **forever** : [read more...](/microbit/reference/basic/forever)
|
||||
* **button is pressed** : [read more...](/microbit/reference/input/button-is-pressed)
|
||||
* **show string** : [read more...](/microbit/reference/basic/show-string)
|
||||
* **show number** : [read more...](/microbit/reference/basic/show-number)
|
||||
* **create image** : [read more...](/microbit/reference/images/create-image)
|
||||
* **show image** : [read more...](/microbit/reference/images/show-image)
|
||||
* **pause** : [read more...](/microbit/reference/basic/pause)
|
||||
|
||||
## Resources
|
||||
|
||||
* Activity: [tutorial](/microbit/lessons/digital-pet/tutorial)
|
||||
* Activity: [quiz](/microbit/lessons/digital-pet/quiz)
|
||||
* Extended Activity: [challenges](/microbit/lessons/digital-pet/challenges)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to create a function as a unit of code that performs a specific task and returns a result
|
||||
* learn how to call an existing function in your script
|
||||
* learn how to create a global variable as a place where you can store data so that you can use it later in your code, accessible across functions and in nested code blocks
|
||||
* learn how to set or change the value of a global variable
|
||||
* learn how to repeat code in the background forever
|
||||
* learn how to get the state of an input button
|
||||
* learn how to show a number on the micro:bit's LED screen
|
||||
* learn how to show a string on the micro:bit's LED screen
|
||||
* learn how to create an image to show on the micro:bit's LED screen
|
||||
* learn how to show an image on the micro:bit's LED screen
|
||||
* learn how to pause your code for the specified number of milliseconds
|
||||
|
||||
## Links to the National Curriculum Programmes of Study for Computing
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* Designs solutions (algorithms) that use repetition and two-way selection, ie if, then and else.(AL)
|
||||
* Uses diagrams to express solutions.(AB)
|
||||
* Uses logical reasoning to predict outputs, showing an awareness of inputs (AL)
|
||||
* Represents solutions using a structured notation (AL) (AB)
|
||||
|
||||
#### Programming & Development
|
||||
|
||||
* Creates programs that implement algorithms to achieve given goals (AL)
|
||||
* Declares and assigns variables(AB)
|
||||
* Uses post-tested loop e.g.‘until’,and a sequence of selection statements in programs,including an if,then and else statement(AL)
|
||||
* Understands the difference between, and appropriately uses if and if, then and else statements(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)
|
||||
* Selects the appropriate data types(AL) (AB
|
||||
|
||||
#### Data & Data Representation
|
||||
|
||||
* Defines data types: real numbers and Boolean (AB)
|
||||
|
||||
#### Communication Networks
|
||||
|
||||
* Demonstrates responsible use of technologies and online services, and knows a range of ways to report concerns Understands how search engines rank search results (AL)
|
||||
|
||||
#### Information Technology
|
||||
|
||||
* Collects, organizes, 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)
|
||||
* Uses criteria to evaluate the quality of solutions, can identify improvements making some refinements to the solution, and future solutions (EV)
|
||||
|
||||
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation
|
||||
|
||||
## Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [tutorial](/microbit/lessons/digital-pet/tutorial)
|
||||
* [quiz](/microbit/lessons/digital-pet/quiz)
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/digital-pet/challenges)
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/digital-pet/challenges)
|
||||
|
||||
## Intended follow on
|
||||
|
||||
Publish script to the classroom.
|
||||
|
129
docs/reference/js/lessons/digital-pet/challenges.md
Normal file
129
docs/reference/js/lessons/digital-pet/challenges.md
Normal file
@ -0,0 +1,129 @@
|
||||
# digital pet challenges
|
||||
|
||||
Coding challenges for the digital pet tutorial.
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following guided tutorial:
|
||||
|
||||
* [tutorial](/microbit/lessons/digital-pet/tutorial)
|
||||
|
||||
At the end of the tutorial, click `keep editing`. Your code should look like this:
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
if (input.buttonIsPressed("A")) {
|
||||
setSleep()
|
||||
basic.pause(5000)
|
||||
} else {
|
||||
setAwake()
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Now let's feed the pet! Add an **ELSE IF** statement that checks if button `B` is pressed. Click on the **ELSE** and type **IF** next to it to get the **ELSE IF**.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
if (input.buttonIsPressed("A")) {
|
||||
setSleep()
|
||||
basic.pause(5000)
|
||||
} else if (input.buttonIsPressed("B")) {
|
||||
|
||||
}
|
||||
else {
|
||||
setAwake()
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 2
|
||||
|
||||
### @video td/videos/digital-pet-2
|
||||
|
||||
Now we want to show your eating pet! Let's create a function called `set eat` that will do create an image. Store that image in a variable and then show it.
|
||||
|
||||
```
|
||||
export function setEat() {
|
||||
let img = images.createImage(`
|
||||
. # . # .
|
||||
. . # . .
|
||||
. . # . .
|
||||
. # . # .
|
||||
. . # . .
|
||||
`)
|
||||
img.showImage(0)
|
||||
}
|
||||
```
|
||||
|
||||
Once you create the function `set eat`, call it in the **ELSE IF** statement that checks if button `B` is pressed.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
if (input.buttonIsPressed("A")) {
|
||||
setSleep()
|
||||
basic.pause(5000)
|
||||
} else if (input.buttonIsPressed("B")) {
|
||||
setEat()
|
||||
}
|
||||
else {
|
||||
setAwake()
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 3
|
||||
|
||||
### @video td/videos/digital-pet-3
|
||||
|
||||
Have your pet tell you when it is going to sleep! Do this inside of the **IF** statement that checks if button `A` is pressed before you call the function `set sleep`.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
if (input.buttonIsPressed("A")) {
|
||||
basic.showString("I am going to sleep.", 150) // ***
|
||||
setSleep()
|
||||
basic.pause(5000)
|
||||
} else if (input.buttonIsPressed("B")) {
|
||||
setEat()
|
||||
}
|
||||
else {
|
||||
setAwake()
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 4
|
||||
|
||||
### @video td/videos/digital-pet-4
|
||||
|
||||
Now, how about we keep track of how many times our pet eats? Add a global variable called `feed` that keeps track of how many times you feed your pet. If button `B` is pressed, increment `feed` by one. Add a condition `on shake` to check your total.
|
||||
|
||||
```
|
||||
feed = 0 // ***
|
||||
basic.forever(() => {
|
||||
if (input.buttonIsPressed("A")) {
|
||||
basic.showString("I am going to sleep.", 150)
|
||||
setSleep()
|
||||
basic.pause(5000)
|
||||
} else if (input.buttonIsPressed("B")) {
|
||||
feed = feed + 1 // ***
|
||||
setEat()
|
||||
}
|
||||
else {
|
||||
setAwake()
|
||||
}
|
||||
})
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
basic.showNumber(feed, 150) // ***
|
||||
}) // ***
|
||||
```
|
||||
|
||||
### Challenge 5
|
||||
|
||||
Program your pet to say that it is hungry after 60 seconds.
|
||||
|
||||
**Hint**: use `input->running time`
|
||||
|
60
docs/reference/js/lessons/digital-pet/quiz-answers.md
Normal file
60
docs/reference/js/lessons/digital-pet/quiz-answers.md
Normal file
@ -0,0 +1,60 @@
|
||||
# digital pet quiz answers
|
||||
|
||||
A display of pet images for the BBC micro:bit
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [digital pet tutorial](/microbit/lessons/digital-pet/tutorial)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. What is a 'function'?
|
||||
|
||||
<br/>
|
||||
|
||||
A function is a unit of code that performs a specific task and may return a result.
|
||||
|
||||
## 2. Write the steps to create the function called set awake()
|
||||
|
||||
<br/>
|
||||
|
||||
Click on "+ add new" and then "function". Click on the function name (by default it is "set awake"), and rename it to "set awake()".
|
||||
|
||||
## 3. Write the code inside the function "set awake()" that shows an image of the pet awake
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
let img = images.createImage(`
|
||||
. # . # .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. # # # .
|
||||
. . . . .
|
||||
`)
|
||||
img.showImage(0)
|
||||
```
|
||||
|
||||
## 4. Write the steps to create the function called set sleep, function set sleep()
|
||||
|
||||
<br/>
|
||||
|
||||
Click on "+ add new" and then "function". Click on the function name (by default it is "set sleep"), and rename it to "set sleep()".
|
||||
|
||||
## 5. Write the code inside the function "set sleep()" that shows an image of the pet asleep
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
img = images.createImage(`
|
||||
# # . # #
|
||||
. . # . .
|
||||
. . . . .
|
||||
. # # # .
|
||||
. . . . .
|
||||
`)
|
||||
img.showImage(0)
|
||||
```
|
||||
|
32
docs/reference/js/lessons/digital-pet/quiz.md
Normal file
32
docs/reference/js/lessons/digital-pet/quiz.md
Normal file
@ -0,0 +1,32 @@
|
||||
# digital pet quiz
|
||||
|
||||
A display of pet images for the BBC micro:bit
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [digital pet tutorial](/microbit/lessons/digital-pet/tutorial)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. What is a 'function'?
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Write the steps to create the function called set awake()
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Write the code inside the function "set awake()" that shows an image of the pet awake
|
||||
|
||||
<br/>
|
||||
|
||||
## 4. Write the steps to create the function called set sleep, function set sleep()
|
||||
|
||||
<br/>
|
||||
|
||||
## 5. Write the code inside the function "set sleep()" that shows an image of the pet asleep
|
||||
|
||||
<br/>
|
||||
|
93
docs/reference/js/lessons/flashing-heart.md
Normal file
93
docs/reference/js/lessons/flashing-heart.md
Normal file
@ -0,0 +1,93 @@
|
||||
# flashing heart lesson
|
||||
|
||||
Learn how to create LED images with a global variable. #LED #screen #plot #docs
|
||||
|
||||
### @video td/videos/flashing-heart-0
|
||||
|
||||
## Topic
|
||||
|
||||
Pause
|
||||
|
||||
## Quick links
|
||||
|
||||
* [activity](/microbit/lessons/flashing-heart/activity)
|
||||
* [quiz](/microbit/lessons/flashing-heart/quiz)
|
||||
* [quiz answers](/microbit/lessons/flashing-heart/quiz-answers)
|
||||
* [challenges](/microbit/lessons/flashing-heart/challenges)
|
||||
* [tutorial](/microbit/lessons/flashing-heart/tutorial)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to **plot image** by turning on a series of LED lights on the LED screen. We will be learning how to create a blinking app using a forever loop as well as simple commands, such as plot image, pause, and clear screen.
|
||||
|
||||
## What the teacher needs to know / QuickStart Computing Glossary
|
||||
|
||||
**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 Forever. Forever will repeats code in the background forever.
|
||||
|
||||
**Command:** An instruction for the computer to execute, written in a particular programming language.**
|
||||
|
||||
## Documentation
|
||||
|
||||
* **forever**: [read more...](/microbit/reference/basic/forever)
|
||||
* **plot image** : [read more...](/microbit/reference/led/plot-image)
|
||||
* **pause**: [read more...](/microbit/reference/basic/pause)
|
||||
* **clear screen**: [read more...](/microbit/reference/basic/clear-screen)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to repeat code in the background forever
|
||||
* learn how to turn on a series of LED lights on the LED screen
|
||||
* learn how to pause your code for the specified number of milliseconds
|
||||
* learn how to turn off all the LED lights on the LED screen
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* 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)
|
||||
* Declares and assigns variables.(AB)
|
||||
|
||||
#### 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
|
||||
|
||||
## Exercise
|
||||
|
||||
* time: 20 min.
|
||||
* [activity](/microbit/lessons/flashing-heart/activity) or [tutorial](/microbit/lessons/flashing-heart/tutorial)
|
||||
* [quiz](/microbit/lessons/flashing-heart/quiz)
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/flashing-heart/challenges)
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/flashing-heart/challenges)
|
||||
|
||||
## Intended follow on
|
||||
|
||||
Publish script to the classroom.
|
||||
|
63
docs/reference/js/lessons/flashing-heart/activity.md
Normal file
63
docs/reference/js/lessons/flashing-heart/activity.md
Normal file
@ -0,0 +1,63 @@
|
||||
# flashing heart activity
|
||||
|
||||
Ccontrol images with variables.
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
### @video td/videos/flashing-heart-0
|
||||
|
||||
In this activity, you will learn how to blink an image on the LED screen.
|
||||
|
||||
### ~
|
||||
|
||||
To create a new script, go to the [Create Code](https://www.microbit.co.uk/create-code) page and tap `New Project` under **KindScript**.
|
||||
|
||||
Let's start by adding code that plots a heart image on the screen using `basic->plot image`. Once you are done coding, don't forget to run your code in the simulator or the BBC micro:bit.
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. # . # .
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`) // ***
|
||||
```
|
||||
|
||||
We want to leave the image on the screen for 0.5 seconds (500 milliseconds), then clear the screen. We can use `basic->pause` to wait and `basic->clear screen` to turn off the LEDs.
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. # . # .
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
basic.pause(500) // ***
|
||||
basic.clearScreen() // ***
|
||||
```
|
||||
|
||||
Finally, we can surround this code with a `basic->forever` loop to repeat it and add a pause after `basic->clear screen` to keep the screen off for a little while. Modify your code so that your code looks like this.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
basic.plotImage(`
|
||||
. # . # .
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
basic.pause(500)
|
||||
basic.clearScreen()
|
||||
basic.pause(500)
|
||||
})
|
||||
```
|
||||
|
||||
### ~avatar boothing
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/microbit/lessons/flashing-heart/challenges)!
|
||||
|
||||
### ~
|
||||
|
93
docs/reference/js/lessons/flashing-heart/challenges.md
Normal file
93
docs/reference/js/lessons/flashing-heart/challenges.md
Normal file
@ -0,0 +1,93 @@
|
||||
# flashing heart challenges
|
||||
|
||||
Coding challenges for flashing heart.
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the [flashing heart](/microbit/lessons/flashing-heart/activity) activity and your code will look like this:
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
basic.plotImage(`
|
||||
. # . # .
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
basic.pause(500)
|
||||
basic.clearScreen()
|
||||
basic.pause(500)
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
### @video td/videos/flashing-heart-1
|
||||
|
||||
Let's plot a different image. Let's display a broken heart!
|
||||
|
||||
To do this, you need to **add a line** between the last line and the end loop. Plot the image of the broken heart and then add a pause of 500 milliseconds.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
basic.plotImage(`
|
||||
# # . # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
basic.pause(500)
|
||||
basic.clearScreen()
|
||||
basic.pause(500)
|
||||
basic.plotImage(`
|
||||
. # . # .
|
||||
# . # # #
|
||||
# . . # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`) // ***
|
||||
basic.pause(500) // ***
|
||||
})
|
||||
```
|
||||
|
||||
* click `run main` to see if the code works as expected.
|
||||
|
||||
### Challenge 2
|
||||
|
||||
### @video td/videos/flashing-heart-2
|
||||
|
||||
Now let's alternate flashing the heart and the broken heart. To do this, we need to clear the screen and then add a pause of 500 milliseconds under the new code we added in Challenge 1.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
basic.plotImage(`
|
||||
# # . # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
basic.pause(500)
|
||||
basic.clearScreen()
|
||||
basic.pause(500)
|
||||
basic.plotImage(`
|
||||
. # . # .
|
||||
# . # # #
|
||||
# . . # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
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.
|
||||
|
102
docs/reference/js/lessons/flashing-heart/lesson-plan.md
Normal file
102
docs/reference/js/lessons/flashing-heart/lesson-plan.md
Normal file
@ -0,0 +1,102 @@
|
||||
# flashing heart lesson plan
|
||||
|
||||
Learn how to create LED images with a variable.
|
||||
|
||||
### @video vimeo/134118661
|
||||
|
||||
## Topic
|
||||
|
||||
Global Variable - Blinking Images
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to control a blinking LED image. We will be learning how to create a blinking app using global variables, forever as well as simple commands, such as create image, show image, pause, and clear screen.
|
||||
|
||||
## 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 Forever. Forever will repeats code in the background forever.
|
||||
|
||||
**Command:** An instruction for the computer to execute, written in a particular programming language.**
|
||||
|
||||
**QuickStart Computing Glossary
|
||||
|
||||
## Documentation
|
||||
|
||||
* **global variables**: [read more...](/microbit/js/data)
|
||||
* **create image** : [read more...](/microbit/reference/images/create-image)
|
||||
* **show image** : [read more...](/microbit/reference/images/show-image)
|
||||
* **pause**: [read more...](/microbit/reference/basic/pause)
|
||||
* **clear screen**: [read more...](/microbit/reference/basic/clear-screen)
|
||||
* **forever**: [read more...](/microbit/reference/basic/forever)
|
||||
|
||||
## Resources
|
||||
|
||||
* Activity: [tutorial](/microbit/lessons/flashing-heart/tutorial)
|
||||
* Activity: [quiz](/microbit/lessons/flashing-heart/quiz)
|
||||
* Extended Activity: [challenges](/microbit/lessons/flashing-heart/challenges)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to create a global variable
|
||||
* learn how to blink a light
|
||||
* 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
|
||||
|
||||
* 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)
|
||||
* Declares and assigns variables.(AB)
|
||||
|
||||
#### 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: 20 min.
|
||||
* [tutorial](/microbit/lessons/flashing-heart/tutorial)
|
||||
* [quiz](/microbit/lessons/flashing-heart/quiz)
|
||||
* assessment opportunities: forever, plot, pause, clear screen
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/flashing-heart/challenges)
|
||||
* assessment opportunities: loops, plot, pause, clear screen
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/flashing-heart/challenges)
|
||||
|
||||
## Intended follow on
|
||||
|
||||
Publish script to the classroom.
|
||||
|
38
docs/reference/js/lessons/flashing-heart/quiz-answers.md
Normal file
38
docs/reference/js/lessons/flashing-heart/quiz-answers.md
Normal file
@ -0,0 +1,38 @@
|
||||
# flashing heart quiz answers
|
||||
|
||||
Learn how to create images with global variables.
|
||||
|
||||
This is the answer key for the [flashing heart quiz](/microbit/lessons/flashing-heart/quiz).
|
||||
|
||||
## 1. Describe what `basic->show leds` does
|
||||
|
||||
Show LEDs displays an Image on the BBC micro:bit's LED screen
|
||||
|
||||
## 2. Draw the areas being displayed on the BBC micro:bit
|
||||
|
||||
```
|
||||
basic.showLeds(`
|
||||
# # . # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`, 400)
|
||||
```
|
||||
|
||||

|
||||
|
||||
## 3. Write the code to show LEDs of a broken heart forever.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
# # . # #
|
||||
# . # # #
|
||||
# # . # #
|
||||
. # . # .
|
||||
. . # . .
|
||||
`, 400)
|
||||
})
|
||||
```
|
||||
|
36
docs/reference/js/lessons/flashing-heart/quiz.md
Normal file
36
docs/reference/js/lessons/flashing-heart/quiz.md
Normal file
@ -0,0 +1,36 @@
|
||||
# flashing heart quiz
|
||||
|
||||
Learn how to create a blinking LED script with a variable.
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [flashing heart activity](/microbit/lessons/flashing-heart/activity).
|
||||
|
||||
Answer the questions while completing the activity. Pay attention to the dialogues!
|
||||
|
||||
## 1. Describe what pause does?
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Draw the image being displayed using the BBC micro:bit image.
|
||||
|
||||
```
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`, 400)
|
||||
```
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Write the code to show LEDs of a broken heart forever.
|
||||
|
||||
<br/>
|
||||
|
124
docs/reference/js/lessons/flipping-bird.md
Normal file
124
docs/reference/js/lessons/flipping-bird.md
Normal file
@ -0,0 +1,124 @@
|
||||
# flipping bird lesson
|
||||
|
||||
count the number of times the BBC micro:bit has been shaken #var #shake #mod #math #plot #docs
|
||||
|
||||
### @video td/videos/flipping-bird-0
|
||||
|
||||
## Topic
|
||||
|
||||
Math - Modulo
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [tutorial](/microbit/lessons/flipping-bird/tutorial)
|
||||
* [quiz](/microbit/lessons/flipping-bird/quiz)
|
||||
* [quiz answers](/microbit/lessons/flipping-bird/quiz-answers)
|
||||
* [challenges](/microbit/lessons/flipping-bird/challenges)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to return the **modulus**, `math->mod` to determine if you will plot image. We will be learning how to return the modulus by using a local variable, input on shake, if (conditional), modulo, as well as simple commands such as plot image.
|
||||
|
||||
## What the teacher needs to know / QuickStart Computing Glossary
|
||||
|
||||
* Algorithm: An unambiguous set of rules or a precise step-bystep guide to solve a problem or achieve a particular objective.
|
||||
* Input: Data provided to a computer system, such as via a keyboard, mouse, microphone, camera or physical sensors.
|
||||
* Output: The information produced by a computer system for its user, typically on a screen, through speakers or on a printer, but possibly through the control of motors in physical systems.
|
||||
* Programmable toys: Robots designed for children to use, accepting input, storing short sequences of simple instructions and moving according to this stored program.
|
||||
* 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.
|
||||
* Repetition: Executing a section of computer code a number of times as part of the program.
|
||||
* Simulation: Using a computer to model the state and behaviour of real-world (or imaginary) systems, including physical or social systems; an integral part of most computer games.
|
||||
* Variables: A way in which computer programs can store, retrieve or change data, such as a score, the time left, or the user’s name.
|
||||
|
||||
## Documentation
|
||||
|
||||
* **global variables** : [read more...](/microbit/js/data)
|
||||
* **on shake** : [read more...](/microbit/reference/input/on-gesture)
|
||||
* **if** : [read more...](/microbit/reference/logic/if)
|
||||
* **math modulo** : [read more...](/microbit/js/math)
|
||||
* **plot image** : [read more...](/microbit/reference/led/plot-image)
|
||||
|
||||
## Resources
|
||||
|
||||
* Activity: [tutorial](/microbit/lessons/flipping-bird/tutorial)
|
||||
* Activity: [quiz](/microbit/lessons/flipping-bird/quiz)
|
||||
* Extended Activity: [challenges](/microbit/lessons/flipping-bird/challenges)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to create a local variable as a place where you can store data, so that you can use it in your code, across functions, and in nested code blocks
|
||||
* learn how to run code when the micro:bit is shaken; when running code in the browser, moving the mouse quickly simulates shaking
|
||||
* learn how to conditionally run code depending on whether a condition is true or not
|
||||
* learn how to return the modulus
|
||||
* learn how to display an image on the BBC micro:bit's LED screen
|
||||
|
||||
## Links to the National Curriculum Programmes of Study for Computing
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* Designs solutions (algorithms) that use repetition and two-way selection, ie if, then and else.(AL)
|
||||
* Uses diagrams to express solutions.(AB)
|
||||
* Uses logical reasoning to predict outputs, showing an awareness of inputs (AL)
|
||||
* Shows an awareness of tasks best completed by humans or computers (EV)
|
||||
* Designs solutions by decomposing a problem and creates a sub-solution for each of these parts. (DE) (AL) (AB)
|
||||
* Recognises that different solutions exist for the same problem (AL) (AB) Understands that iteration is the repetition of a process such as a loop (AL)
|
||||
* Recognises that different algorithms exist for the same problem (AL) (GE)
|
||||
* Represents solutions using a structured notation (AL) (AB)
|
||||
* Can identify similarities and differences in situations and can use these to solve problems (pattern recognition)(GE)
|
||||
|
||||
#### Programming & Development
|
||||
|
||||
* Creates programs that implement algorithms to achieve given goals (AL)
|
||||
* Declares and assigns variables(AB)
|
||||
* Uses post-tested loop e.g.‘until’,and a sequence of selection statements in programs,including an if,then and else statement(AL)
|
||||
* Understands the difference between, and appropriately uses if and if, then and else statements(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)
|
||||
* Selects the appropriate data types(AL) (AB
|
||||
|
||||
#### Data & Data Representation
|
||||
|
||||
* Understands the difference between data and information(AB)
|
||||
* Uses filters or can perform single criteria searches for information.(AL)
|
||||
* Performs more complex searches for information e.g. using Boolean and relational operators(AL) (GE) (EV)
|
||||
* Defines data types: real numbers and Boolean (AB)
|
||||
|
||||
#### Hardware & Processing
|
||||
|
||||
* Knows that computers collect data from various input devices, including sensors and application software (AB)
|
||||
|
||||
#### Information Technology
|
||||
|
||||
* Collects, organizes, 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)
|
||||
* Uses criteria to evaluate the quality of solutions, can identify improvements making some refinements to the solution, and future solutions (EV)
|
||||
* Recognises ethical issues surrounding the application of information technology beyond school.
|
||||
|
||||
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation
|
||||
|
||||
## Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [tutorial](/microbit/lessons/flipping-bird/tutorial)
|
||||
* [quiz](/microbit/lessons/flipping-bird/quiz)
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/flipping-bird/challenges)
|
||||
* assessment opportunities: loops, plot, pause, clear screen
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/flipping-bird/challenges)
|
||||
|
||||
## Intended follow on
|
||||
|
||||
Publish script to the classroom.
|
||||
|
87
docs/reference/js/lessons/flipping-bird/challenges.md
Normal file
87
docs/reference/js/lessons/flipping-bird/challenges.md
Normal file
@ -0,0 +1,87 @@
|
||||
# flipping bird challenges
|
||||
|
||||
Coding challenges for flipping bird. #docs
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following guided tutorial:
|
||||
|
||||
* [tutorial](/microbit/lessons/flipping-bird/tutorial)
|
||||
|
||||
At the end of the tutorial, click `keep editing`. Your code should look like this:
|
||||
|
||||
```
|
||||
counter = 0
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
counter = counter + 1
|
||||
if (math.mod(counter, 2) == 1) {
|
||||
basic.plotImage(`
|
||||
# # . # #
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
We handled the case of when `math->mod(counter,2) = 1`. We haven't done anything when the remainder is 0! Add an if statement to handle this case.
|
||||
|
||||
```
|
||||
counter = 0
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
counter = counter + 1
|
||||
if (math.mod(counter, 2) == 1) {
|
||||
basic.plotImage(`
|
||||
# # . # #
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
if (math.mod(counter, 2) == 0) {
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 2
|
||||
|
||||
### @video td/videos/flipping-bird-2
|
||||
|
||||
Inside of that `if` statement you created in challenge 1, add `basic->plot image()` and display an upside down flying bird.
|
||||
|
||||
```
|
||||
counter = 0
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
counter = counter + 1
|
||||
if (math.mod(counter, 2) == 1) {
|
||||
basic.plotImage(`
|
||||
# # . # #
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
if (math.mod(counter, 2) == 0) {
|
||||
basic.plotImage(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
# # . # #
|
||||
`) // ***
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
* `Run` the code to see if it works as expected.
|
||||
|
||||
**Challenge 3**
|
||||
|
||||
Display a check mark and question mark instead of flipping birds. Or better yet, come up with your own pair of opposites to display!
|
||||
|
50
docs/reference/js/lessons/flipping-bird/quiz-answers.md
Normal file
50
docs/reference/js/lessons/flipping-bird/quiz-answers.md
Normal file
@ -0,0 +1,50 @@
|
||||
# flipping bird quiz answers
|
||||
|
||||
use modulo with a conditional #mod #shake #variables #docs #input #mod
|
||||
|
||||
This is the answer key for the [flipping bird quiz](/microbit/lessons/flipping-bird/quiz).
|
||||
|
||||
## 1. What does "modulo" mean in math?
|
||||
|
||||
<br/>
|
||||
|
||||
Modulo (or Mod) is the remainder of a division problem.
|
||||
|
||||
## 2. Consider the following code
|
||||
|
||||
If the rectangle below represents the BBC micro:bit, shade in the LEDs that show the value being stored into the **global variable**, `count`. Explain why that particular area is shaded.
|
||||
|
||||
```
|
||||
count = 1
|
||||
count_ = count_ + 2
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||

|
||||
|
||||
The variable `count` is now equal to 3.
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Consider the following directions
|
||||
|
||||
Modulo (Mod) tells us what the remainder of a division is. For example, `15 mod 4 is 3` since 15 divided by 4 has a remainder of 3.
|
||||
|
||||
```
|
||||
count = 12
|
||||
count = math.mod(count, 5)
|
||||
```
|
||||
|
||||
If the rectangle below represents the BBC micro:bit, shade in the LEDs that show the value being stored into the **global variable**, `count`. Explain why that particular area is shaded.
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||

|
||||
|
||||
The display will show `2` because the remainder of 12 divided by 5 is 2.
|
||||
|
60
docs/reference/js/lessons/flipping-bird/quiz.md
Normal file
60
docs/reference/js/lessons/flipping-bird/quiz.md
Normal file
@ -0,0 +1,60 @@
|
||||
# flipping bird quiz
|
||||
|
||||
use modulo with a conditional #mod #shake #variables #docs #input #mod
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [flipping bird tutorial](/microbit/lessons/flipping-bird/tutorial).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. What does "modulo" mean in math?
|
||||
|
||||
## 2. Consider the following directions
|
||||
|
||||
If the rectangle below represents the BBC micro:bit, shade in the LEDs that show the value being stored into the **global variable**, `count`.
|
||||
|
||||
```
|
||||
count = 1
|
||||
```
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Consider the following code
|
||||
|
||||
If the rectangle below represents the BBC micro:bit, shade in the LEDs that show the value being stored into the **global variable**, `count`. Explain why that particular area is shaded.
|
||||
|
||||
```
|
||||
count = 1
|
||||
count_ = count_ + 2
|
||||
```
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 4. Consider the following directions
|
||||
|
||||
Modulo (Mod) tells us what the remainder of a division is. For example, `15 mod 4 is 3` since 15 divided by 4 has a remainder of 3.
|
||||
|
||||
```
|
||||
count = 12
|
||||
count = math.mod(count, 5)
|
||||
```
|
||||
|
||||
If the rectangle below represents the BBC micro:bit, shade in the LEDs that show the value being stored into the **global variable**, `count`. Explain why that particular area is shaded.
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
191
docs/reference/js/lessons/foo.md
Normal file
191
docs/reference/js/lessons/foo.md
Normal file
@ -0,0 +1,191 @@
|
||||
# foo
|
||||
|
||||
blank lesson #docs
|
||||
|
||||
### ~screen TODO
|
||||
|
||||
### @video vimeo/134121040
|
||||
|
||||
### ~
|
||||
|
||||
## Topic TODO:
|
||||
|
||||
Basic - Show Number
|
||||
|
||||
## Quick Links TODO:
|
||||
|
||||
* [tutorial](/microbit/lessons/lucky-7/tutorial)
|
||||
* [quiz](/microbit/lessons/lucky-7/quiz)
|
||||
* [quiz answers](/microbit/lessons/lucky-7/quiz-answers)
|
||||
* [challenges](/microbit/lessons/lucky-7/challenges)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work TODO:
|
||||
|
||||
Learn how to creating a **global number variable**, `data->count` to keep track of the current count. We will be learning how to create a counter app using global variables as well as simple commands, such as on button pressed, and show number.
|
||||
|
||||
## What the teacher needs to know TODO:
|
||||
|
||||
* Acceptable Use Policy (AUP): An Acceptable Use Policy comprises a set of rules applied by the owner/manager of a network, website or large computer system that defines the ways in which the network, site or system may be used.
|
||||
* Algorithm: An unambiguous set of rules or a precise step-bystep guide to solve a problem or achieve a particular objective.
|
||||
* Command: An instruction for the computer to execute, written in a particular programming language.
|
||||
* Computational thinking: Thinking about systems or problems in a way that allows computer systems to be used to model or solve these.
|
||||
* Computer networks: The computers and the connecting hardware (wifi access points, cables, fibres, switches and routers) that make it possible to transfer data using an agreed method (‘protocol’).
|
||||
* Creative Commons: A licensing scheme where the creator of an original work allows others to use it without seeking further permission, subject to a number of agreed conditions: www. creativecommons.org.
|
||||
* Data: A structured set of numbers, possibly representing digitised text, images, sound or video, which can be processed or transmitted by a computer, also used for numerical (quantitative) information.
|
||||
* Debug: To fix the errors in a program.
|
||||
* Decomposing: The process through which problems or systems are broken down into their component parts, each of which may then be considered separately.
|
||||
* Domain Name Service (DNS): The distributed automatic system that converts domain names into the IP addresses which are used for routing packets via the internet.
|
||||
* Encrypt: To securely encode information so that it can only be read by those knowing both the system used and a secret, private key.
|
||||
* E-safety: Used to describe behaviours and policies intended to minimise the risks to a user of using digital technology, particularly the internet.
|
||||
* Generalisation: A computational thinking process in which general solutions or models are preferred to or derived from particular cases.
|
||||
* Hardware: The physical systems and components of digital devices; see also software.
|
||||
* Hypertext mark-up language (HTML): HTML is the language in which web pages are composed.
|
||||
* Hypertext transfer protocol (HTTP): HTTP is the standard protocol for the request and transmission of HTML web pages between browser and web server.
|
||||
* Input: Data provided to a computer system, such as via a keyboard, mouse, microphone, camera or physical sensors.
|
||||
* Interface: The boundary between one system and another – often used to describe how a person interacts with a computer.
|
||||
* Internet Protocol (IP) addresses: Numeric addresses uniquely specifying computers directly connected to the internet, also used on private networks to uniquely identify computers on that network.
|
||||
* Loop: A block of code repeated automatically under the program’s control.
|
||||
* Network server: A computer connected to a local area network providing services – such as file storage, printing, authentication, web access or email – automatically to other computers on the network.
|
||||
* Open source software: Software in which the source code is made available for others to study, and typically adapt, usually with few if any restrictions.
|
||||
* Operating system: The programs on a computer which deal with internal management of memory, input/output, security and so on, such as Windows 8 or iOS.
|
||||
* Output: The information produced by a computer system for its user, typically on a screen, through speakers or on a printer, but possibly through the control of motors in physical systems.
|
||||
* Packets of data: A small set of numbers that get transmitted together via the internet, typically enough for 1000 or 1500 characters.
|
||||
* Programmable toys: Robots designed for children to use, accepting input, storing short sequences of simple instructions and moving according to this stored program.
|
||||
* 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.
|
||||
* Repetition: Executing a section of computer code a number of times as part of the program.
|
||||
* Router: Network hardware which forwards packets of data onwards to the most appropriate hardware to which it is connected.
|
||||
* Screencast: A recording of on-screen action that is often accompanied by an audio narration.
|
||||
* Script: A computer program typically executed one line at a time through an interpreter, such as the instructions for a Scratch character.
|
||||
* Selection: A programming construct in which one section of code or another is executed depending on whether a particular condition is met.
|
||||
* Sequence: To place program instructions in order, with each executed one after the other.
|
||||
* Simulation: Using a computer to model the state and behaviour of real-world (or imaginary) systems, including physical or social systems; an integral part of most computer games.
|
||||
* Sprite: A computer graphics object that can be controlled (programmed) independently of other objects or the background.
|
||||
* Uniform Resource Locator (URL): A standard for specifying the location on the internet of certain files.
|
||||
* Variables: A way in which computer programs can store, retrieve or change data, such as a score, the time left, or the user’s name.
|
||||
* Web server: A service running on a computer (or sometimes for the computer itself) that returns HTML data for a web page when it receives an HTTP request via the local network or the internet.
|
||||
* World Wide Web: A service provided by computers connected to the internet (web servers), in which pages of hypertext (web pages) are transmitted to users.
|
||||
|
||||
**QuickStart Computing Glossary
|
||||
|
||||
## Documentation TODO:
|
||||
|
||||
* **show number** : [read more...](/microbit/reference/basic/show-number)
|
||||
|
||||
## Resources TODO:
|
||||
|
||||
* Activity: [tutorial](/microbit/lessons/lucky-7/tutorial)
|
||||
* Activity: [quiz](/microbit/lessons/lucky-7/quiz)
|
||||
* Extended Activity: [challenges](/microbit/lessons/lucky-7/challenges)
|
||||
|
||||
## Objectives TODO:
|
||||
|
||||
* learn how to create a global variable
|
||||
* learn how to blink a light
|
||||
* learn how to repeat turning on and off the light
|
||||
|
||||
## Links to the National Curriculum Programmes of Study for Computing TODO:
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework TODO:
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* Designs solutions (algorithms) that use repetition and two-way selection, ie if, then and else.(AL)
|
||||
* Uses diagrams to express solutions.(AB)
|
||||
* Uses logical reasoning to predict outputs, showing an awareness of inputs (AL)
|
||||
* Shows an awareness of tasks best completed by humans or computers (EV)
|
||||
* Designs solutions by decomposing a problem and creates a sub-solution for each of these parts. (DE) (AL) (AB)
|
||||
* Recognises that different solutions exist for the same problem (AL) (AB) Understands that iteration is the repetition of a process such as a loop (AL)
|
||||
* Recognises that different algorithms exist for the same problem (AL) (GE)
|
||||
* Represents solutions using a structured notation (AL) (AB)
|
||||
* Can identify similarities and differences in situations and can use these to solve problems (pattern recognition)(GE)
|
||||
|
||||
#### Programming & Development
|
||||
|
||||
* Creates programs that implement algorithms to achieve given goals (AL)
|
||||
* Declares and assigns variables(AB)
|
||||
* Uses post-tested loop e.g.‘until’,and a sequence of selection statements in programs,including an if,then and else statement(AL)
|
||||
* Understands the difference between, and appropriately uses if and if, then and else statements(AL)
|
||||
* Uses a variable and relational operators within a loop to govern termination (AL) (GE)
|
||||
* Designs, writes and debugs modular programs using procedures(AL) (DE) (AB) (GE)
|
||||
* Knows that a procedure can be used to hide the detail with sub-solution(AL) (DE) (AB) (GE)
|
||||
* Understands that programming bridges the gap between algorithmic solutions and computers(AB)
|
||||
* Has practical experience of a high-level textual language, including using standard libraries when programming(AB) (AL)
|
||||
* Uses a range of operators and expressions e.g. Boolean, and applies them in the context of program control. (AL)
|
||||
* Selects the appropriate data types(AL) (AB
|
||||
|
||||
#### Data & Data Representation
|
||||
|
||||
* Understands the difference between data and information(AB)
|
||||
* Knows why sorting data in a flat file can improve searching for information (EV)
|
||||
* Uses filters or can perform single criteria searches for information.(AL)
|
||||
* Performs more complex searches for information e.g. using Boolean and relational operators(AL) (GE) (EV)
|
||||
* Analyses and evaluates data and information, and recognises that poor quality data leads to unreliable re sults,and inaccurate conclusions (AL) (EV)
|
||||
* Knows that digital computers use binary to represent all data (AB)
|
||||
* Understands how bit patterns represent numbers and images (AB)
|
||||
* Knows that computers transfer data in binary (AB)
|
||||
* Understands the relationship between binary and file size (uncompressed) (AB)
|
||||
* Defines data types: real numbers and Boolean (AB)
|
||||
* Queries data on one table using a typical query language (AB)
|
||||
|
||||
#### Hardware & Processing
|
||||
|
||||
* Knows that computers collect data from various input devices, including sensors and application software (AB)
|
||||
* Understands the difference between hardware and application software, and their roles within a computer system (AB)
|
||||
* Understands why and when computers are used (EV)
|
||||
* Understands the main functions of the operating system (DE) (AB)
|
||||
* Knows the difference between physical, wireless and mobile networks (AB)
|
||||
* Recognises and understands the function of the main internal parts of basic computer architecture (AB)
|
||||
* Understands the concepts behind the fetch-execute cycle (AB) (AL)
|
||||
* Knows that there is a range of operating systems and application software for the same hardware (AB)
|
||||
|
||||
#### Communication Networks
|
||||
|
||||
* Understands the difference between the internet and internet service e.g. world wide web (AB)
|
||||
* Shows an awareness of, and can use a range of internet services e.g. VOIP.
|
||||
* Understands why and when computers are used (EV)
|
||||
* Selects, combines and uses internet services (EV)
|
||||
* Demonstrates responsible use of technologies and online services, and knows a range of ways to report concerns Understands how search engines rank search results (AL)
|
||||
* Understands how to construct static web pages using HTML and CSS (AL) (AB)
|
||||
* Understands data transmission between digital computers over networks, including the internet i.e. IP addresses and packet switching. (AL) (AB)
|
||||
|
||||
#### Information Technology
|
||||
|
||||
Collects, organizes, and presents data and information in digital content (AB)
|
||||
|
||||
* Creates digital content to achieve a given goal through combining software packages and internet services to communicate with a wider audience e.g. blogging (AL)
|
||||
* Makes appropriate improvements to solutions based on feedback received, and can comment on the success of the solution (EV)
|
||||
* * Makes judgements about digital content when evaluating and repurposing it for a given audience (EV) (GE)
|
||||
* Recognises the audience when designing and creating digital content (EV)
|
||||
* Understands the potential of information technology for collaboration when computers are networked (GE)
|
||||
* Uses criteria to evaluate the quality of solutions, can identify improvements making some refinements to the solution, and future solutions (EV)
|
||||
* Evaluates the appropriatness of digital devices, internet services and application software to achieve given goals (EV)
|
||||
* Recognises ethical issues surrounding the application of information technology beyond school.
|
||||
* Designs criteria to critically evaluate the quality of solutions, uses the criteria to identify improvements and can make appropriate refinements to the solution (EV)
|
||||
|
||||
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation
|
||||
|
||||
## Activity TODO:
|
||||
|
||||
* time: 20 min.
|
||||
* [tutorial](/microbit/lessons/lucky-7/tutorial)
|
||||
* [quiz](/microbit/lessons/lucky-7/quiz)
|
||||
* assessment opportunities: forever, plot, pause, clear screen
|
||||
|
||||
## Extended Activity TODO:
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/lucky-7/challenges)
|
||||
* assessment opportunities: loops, plot, pause, clear screen
|
||||
|
||||
## Homework TODO:
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/lucky-7/challenges)
|
||||
|
||||
## Intended follow on
|
||||
|
||||
Publish script to the classroom.
|
||||
|
41
docs/reference/js/lessons/for-loop/challenges.md
Normal file
41
docs/reference/js/lessons/for-loop/challenges.md
Normal file
@ -0,0 +1,41 @@
|
||||
# looper challenges
|
||||
|
||||
These challenges will allow you to create a counter from 0-5 and then from 5-0. #docs
|
||||
|
||||
### Challenge 0
|
||||
|
||||
Welcome! This [guided tutorial](/microbit/bcvgkf) will assist you with the following activity:
|
||||
|
||||
```
|
||||
for (let i = 0; i < 6; i++) {
|
||||
led.showNumber(i, 150)
|
||||
basic.pause(2000)
|
||||
}
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Go through the loop faster by changing the length of the pause. This is the line you will be editing: `basic->pause(2000)`
|
||||
|
||||
```
|
||||
for (let i1 = 0; i1 < 6; i1++) {
|
||||
basic.showNumber(i1, 150)
|
||||
basic.pause(500) // ***
|
||||
}
|
||||
```
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Now, let's count down from 5 instead of counting up to 5. Change the line `basic->show number(i, 150)` to `basic->show number(5 - i, 150)`.
|
||||
|
||||
```
|
||||
for (let i2 = 0; i2 < 6; i2++) {
|
||||
basic.showNumber(5 - i2, 150) // ***
|
||||
basic.pause(2000)
|
||||
}
|
||||
```
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Have the number count up in 2's from zero. It should go: 0, 2, 4, 6, 8, 10.
|
||||
|
56
docs/reference/js/lessons/glowing-image/challenges.md
Normal file
56
docs/reference/js/lessons/glowing-image/challenges.md
Normal file
@ -0,0 +1,56 @@
|
||||
# glowing mountain challenges
|
||||
|
||||
These challenges will help you display a glowing image that fades in and out at different speeds. #docs
|
||||
|
||||
**Challenge 0**
|
||||
|
||||
[This guided tutorial](https://test.microbit.co.uk/td/lessons/glowing-mountain/tutorial) will teach you how to create a mountain that fades out.
|
||||
|
||||
```
|
||||
images.createImage(`
|
||||
. . . . .
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
# # # # #
|
||||
`).showImage(0)
|
||||
led.fadeOut(700)
|
||||
```
|
||||
|
||||
**Challenge 1**
|
||||
|
||||
Now, let's add `basic->pause(1000)` after the fade in so that there will be a 1000 millisecond delay after the fade out.
|
||||
|
||||
```
|
||||
images.createImage(`
|
||||
. . . . .
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
# # # # #
|
||||
`).showImage(0)
|
||||
led.fadeOut(700)
|
||||
basic.pause(1000) // ***
|
||||
```
|
||||
|
||||
**Challenge 2**
|
||||
|
||||
After the pause, let's add `led->fade in(2000)` so that we can create a glowing effect.
|
||||
|
||||
```
|
||||
images.createImage(`
|
||||
. . . . .
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
# # # # #
|
||||
`).showImage(0)
|
||||
led.fadeOut(700)
|
||||
basic.pause(1000)
|
||||
led.fadeIn(2000) // ***
|
||||
```
|
||||
|
||||
**Challenge 3**
|
||||
|
||||
Now add another `basic->pause(1000)` and `led->fade out(900)` so that the mountain can fade out again.
|
||||
|
64
docs/reference/js/lessons/glowing-mountain/challenges.md
Normal file
64
docs/reference/js/lessons/glowing-mountain/challenges.md
Normal file
@ -0,0 +1,64 @@
|
||||
# glowing sword challenges
|
||||
|
||||
These challenges will help you display a glowing image that fades in and out at different speeds. #docs
|
||||
|
||||
**Challenge 0**
|
||||
|
||||
### @video vimeo/134649269
|
||||
|
||||
[This guided tutorial](https://test.microbit.co.uk/td/lessons/glowing-mountain/tutorial) will teach you how to create a mountain that fades out.
|
||||
|
||||
```
|
||||
images.createImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
# # # . .
|
||||
. # # . .
|
||||
# . # # .
|
||||
`).showImage(0)
|
||||
led.fadeOut(700)
|
||||
```
|
||||
|
||||
**Challenge 1**
|
||||
|
||||
Now, let's add `basic->pause(1000)` after the fade in so that there will be a 1000 millisecond delay after the fade out.
|
||||
|
||||
```
|
||||
images.createImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
# # # . .
|
||||
. # # . .
|
||||
# . # # .
|
||||
`).showImage(0)
|
||||
led.fadeOut(700)
|
||||
basic.pause(1000) // ***
|
||||
```
|
||||
|
||||
* Run the code to see if it works as expected.
|
||||
|
||||
**Challenge 2**
|
||||
|
||||
### @video vimeo/134674595
|
||||
|
||||
After the pause, let's add `led->fade in(2000)` so that we can create a glowing effect.
|
||||
|
||||
```
|
||||
images.createImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
# # # . .
|
||||
. # # . .
|
||||
# . # # .
|
||||
`).showImage(0)
|
||||
led.fadeOut(700)
|
||||
basic.pause(1000)
|
||||
led.fadeIn(2000) // ***
|
||||
```
|
||||
|
||||
* Run the code to see if it works as expected.
|
||||
|
||||
**Challenge 3**
|
||||
|
||||
Now add another `basic->pause(1000)` and `led->fade out(900)` so that the mountain can fade out again.
|
||||
|
90
docs/reference/js/lessons/glowing-pendulum.md
Normal file
90
docs/reference/js/lessons/glowing-pendulum.md
Normal file
@ -0,0 +1,90 @@
|
||||
# glowing pendulum lesson
|
||||
|
||||
construct a pendulum that glows using acceleration #var #acceleration #abs #brightness #plot #docs
|
||||
|
||||
## Topic
|
||||
|
||||
Acceleration
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [activity](/microbit/lessons/glowing-pendulum/activity)
|
||||
* [challenges](/microbit/lessons/glowing-pendulum/challenges)
|
||||
* [quiz](/microbit/lessons/glowing-pendulum/quiz)
|
||||
* [quiz answers](/microbit/lessons/glowing-pendulum/quiz-answers)
|
||||
* [tutorial](/microbit/lessons/glowing-pendulum/tutorial)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to get the acceleration **acceleration**, `input->acceleration` value (g-force), in one of three specified dimensions. We will be learning how to get the acceleration using forever loop, a local variable, acceleration, the math library, as well as simple commands, such as led set brightness and led plot all.
|
||||
|
||||
## Documentation
|
||||
|
||||
* **forever** : [read more...](/microbit/reference/basic/forever)
|
||||
* **local variable** : [read more...](/microbit/reference/variables/var)
|
||||
* **acceleration** : [read more...](/microbit/reference/input/acceleration)
|
||||
* **absolute value** : [read more...](/microbit/js/math)
|
||||
* **set brightness** : [read more...](/microbit/reference/led/set-brightness)
|
||||
* **plot** : [read more...](/microbit/reference/led/set-brightness)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to repeat code in the background forever
|
||||
* learn how create a local variable to store data, so that you can use it in your code
|
||||
* learn how to get the acceleration value (g-force), in one of three specified dimensions
|
||||
* learn how to return the absolute value
|
||||
* learn how to sets the brightness of the LED screen
|
||||
* learn how to turn on all the LED lights on the LED screen
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* Uses diagrams to express solutions.(AB)
|
||||
* Uses logical reasoning to predict outputs, showing an awareness of inputs (AL)
|
||||
* Represents solutions using a structured notation (AL) (AB)
|
||||
|
||||
#### Programming & Development
|
||||
|
||||
* Creates programs that implement algorithms to achieve given goals (AL)
|
||||
* Declares and assigns variables(AB)
|
||||
* Uses a variable and relational operators within a loop to govern termination (AL) (GE)
|
||||
* Selects the appropriate data types(AL) (AB
|
||||
|
||||
#### Data & Data Representation
|
||||
|
||||
* Understands the difference between data and information(AB)
|
||||
* Uses filters or can perform single criteria searches for information.(AL)
|
||||
|
||||
#### Hardware & Processing
|
||||
|
||||
* Knows that computers collect data from various input devices, including sensors and application software (AB)
|
||||
|
||||
#### Information Technology
|
||||
|
||||
* Collects, organizes, 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)
|
||||
* Recognises ethical issues surrounding the application of information technology beyond school.
|
||||
|
||||
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation
|
||||
|
||||
## Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [activity](/microbit/lessons/glowing-pendulum/activity)
|
||||
* [tutorial](/microbit/lessons/glowing-pendulum/tutorial)
|
||||
* [quiz](/microbit/lessons/glowing-pendulum/quiz)
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/glowing-pendulum/challenges)
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/glowing-pendulum/challenges)
|
||||
|
75
docs/reference/js/lessons/glowing-pendulum/activity.md
Normal file
75
docs/reference/js/lessons/glowing-pendulum/activity.md
Normal file
@ -0,0 +1,75 @@
|
||||
# glowing pendulum activity
|
||||
|
||||
construct a pendulum that glows using acceleration. #docs
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Welcome! This guided activity will teach how to construct a pendulum that glows using acceleration. Let's get started!
|
||||
|
||||
### ~
|
||||
|
||||
To create a new script, go to the [Create Code](/microbit/create-code) page and tap *New Project* under **Touch Develop**.
|
||||
|
||||
Create a **forever** loop that will constantly display the appropriate brightness on the LED display.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
})
|
||||
```
|
||||
|
||||
Now let's measure the acceleration on the `y` axis and store that value in a variable. The `input->acceleration("y")` function will provide the value.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
let acceleration = input.acceleration("y")
|
||||
})
|
||||
```
|
||||
|
||||
Since the micro:bit will be swinging back and forth, the acceleration will only be positive half of the time. Thus, to always get a positive value, we want to take the absolute value of the acceleration.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
let acceleration1 = input.acceleration("y")
|
||||
acceleration1 = math.abs(acceleration1)
|
||||
})
|
||||
```
|
||||
|
||||
The function `input->acceleration("y")` returns a number between 0 and 1024. We want to use this value for the brightness of the micro:bit, but the `led->set brightness()` only accepts a value between 0 and 256. Thus, we need to divide the acceleration by 4 to ensure we will be in the appropriate range.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
let acceleration2 = input.acceleration("y")
|
||||
acceleration2 = math.abs(acceleration2)
|
||||
acceleration2 = acceleration2 / 4
|
||||
})
|
||||
```
|
||||
|
||||
Now let's use our acceleration value to set the brightness on the BBC micro:bit.
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
let acceleration3 = input.acceleration("y")
|
||||
acceleration3 = math.abs(acceleration3)
|
||||
acceleration3 = acceleration3 / 4
|
||||
led.setBrightness(acceleration3)
|
||||
})
|
||||
```
|
||||
|
||||
Let's show what the brightness of the micro:bit is by turning all the LEDs on!
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
let acceleration4 = input.acceleration("y")
|
||||
acceleration4 = math.abs(acceleration4)
|
||||
acceleration4 = acceleration4 / 4
|
||||
led.setBrightness(acceleration4)
|
||||
led.plotAll()
|
||||
})
|
||||
```
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/microbit/lessons/glowing-pendulum/challenges)!
|
||||
|
||||
### ~
|
||||
|
32
docs/reference/js/lessons/glowing-pendulum/challenges.md
Normal file
32
docs/reference/js/lessons/glowing-pendulum/challenges.md
Normal file
@ -0,0 +1,32 @@
|
||||
# glowing pendulum challenges
|
||||
|
||||
Coding challenges for the glowing pendulum tutorial. #docs
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following guided tutorial:
|
||||
|
||||
* [tutorial](/microbit/lessons/glowing-pendulum/tutorial)
|
||||
|
||||
At the end of the tutorial, click `keep editing`. Your code should look like this:
|
||||
|
||||
```
|
||||
basic.forever(() => {
|
||||
let acceleration = input.acceleration("y")
|
||||
acceleration = math.abs(acceleration)
|
||||
acceleration = acceleration / 4
|
||||
led.setBrightness(acceleration)
|
||||
led.plotAll()
|
||||
})
|
||||
```
|
||||
|
||||
**Challenge 1**
|
||||
|
||||

|
||||
|
||||
Hold the BBC micro:bit in your hand in a dark room. Move the BBC micro:bit like a pendulum, and produce a slow image that captures the pattern of the BBC micro:bit LEDs.
|
||||
|
||||
**Challenge 2**
|
||||
|
||||
Replace "y" in `[input->acceleration("y")] with "x" or "z". Changing the axis will cause the BBC micro:bit to measure the force in a different direction. What differences in the resulting pattern does this replacement make?
|
||||
|
53
docs/reference/js/lessons/glowing-pendulum/quiz-answers.md
Normal file
53
docs/reference/js/lessons/glowing-pendulum/quiz-answers.md
Normal file
@ -0,0 +1,53 @@
|
||||
# glowing pendulum quiz answers
|
||||
|
||||
construct a pendulum that glows using acceleration #LED #number #math #acceleration #docs
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [glowing pendulum tutorial](/microbit/lessons/glowing-pendulum/tutorial)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Why are you creating a 'forever' loop?
|
||||
|
||||
<br/>
|
||||
|
||||
We are creating a forever loop to constantly display the appropriate brightness on the LED display.
|
||||
|
||||
## 2. Write the line of code to measure the acceleration with respect to the "y" axis and store this value in a local variable called 'acceleration'.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
let acceleration = input.acceleration("y")
|
||||
```
|
||||
|
||||
## 3. After storing the acceleration in a variable, write the code to take the absolute value of the acceleration, and store this value inside 'acceleration'.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
acceleration = math.abs(acceleration)
|
||||
```
|
||||
|
||||
## 4. Write the code that uses the acceleration value from question #3 to set the brightness on the BBC micro:bit.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
acceleration = acceleration / 4
|
||||
led.setBrightness(acceleration)
|
||||
```
|
||||
|
||||
## 5. Write the code that tuns all the LEDs on (as the image displays below)
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
led.plotAll()
|
||||
```
|
||||
|
34
docs/reference/js/lessons/glowing-pendulum/quiz.md
Normal file
34
docs/reference/js/lessons/glowing-pendulum/quiz.md
Normal file
@ -0,0 +1,34 @@
|
||||
# glowing pendulum quiz
|
||||
|
||||
construct a pendulum that glows using acceleration #LED #number #math #acceleration #docs
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [glowing pendulum tutorial](/microbit/lessons/glowing-pendulum/tutorial)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Why are you creating a 'forever' loop?
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Write the line of code to measure the acceleration with respect to the "y" axis and store this value in a local variable called 'acceleration'.
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. After storing the acceleration in a variable, write the code to take the absolute value of the acceleration, and store this value inside 'acceleration'.
|
||||
|
||||
<br/>
|
||||
|
||||
## 4. Write the code that uses the acceleration value from question #3 to set the brightness on the BBC micro:bit.
|
||||
|
||||
<br/>
|
||||
|
||||
## 5. Write the code that tuns all the LEDs on (as the image displays below)
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
97
docs/reference/js/lessons/glowing-sword.md
Normal file
97
docs/reference/js/lessons/glowing-sword.md
Normal file
@ -0,0 +1,97 @@
|
||||
# glowing sword lesson
|
||||
|
||||
make a glowing sword #image #docs
|
||||
|
||||
### @video td/videos/glowing-sword-0
|
||||
|
||||
## Topic
|
||||
|
||||
Fade Out
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [activity](/microbit/lessons/glowing-sword/activity)
|
||||
* [quiz](/microbit/lessons/glowing-sword/quiz)
|
||||
* [quiz answers](/microbit/lessons/glowing-sword/quiz-answers)
|
||||
* [challenges](/microbit/lessons/glowing-sword/challenges)
|
||||
* [tutorial](/microbit/lessons/glowing-sword/tutorial)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to manipulate an image through **fade out**, `led->fade out` to gradually decrease the LED screen brightness until the LED lights are turned off. We will be learning how to fade an image using simple commands, such as plot image, fade out, pause, and fade in.
|
||||
|
||||
## What the teacher needs to know/QuickStart Computing Glossary
|
||||
|
||||
* Algorithm: An unambiguous set of rules or a precise step-bystep guide to solve a problem or achieve a particular objective.
|
||||
* Computational thinking: Thinking about systems or problems in a way that allows computer systems to be used to model or solve these.
|
||||
* Hardware: The physical systems and components of digital devices; see also software.
|
||||
* Programmable toys: Robots designed for children to use, accepting input, storing short sequences of simple instructions and moving according to this stored program.
|
||||
* Script: A computer program typically executed one line at a time through an interpreter, such as the instructions for a Scratch character.
|
||||
* Sequence: To place program instructions in order, with each executed one after the other.
|
||||
* Simulation: Using a computer to model the state and behaviour of real-world (or imaginary) systems, including physical or social systems; an integral part of most computer games.
|
||||
|
||||
## Documentation
|
||||
|
||||
* **plot image** : [read more...](/microbit/reference/led/plot-image)
|
||||
* **fade out** : [read more...](/microbit/reference/led/fade-out)
|
||||
* **pause** : [read more...](/microbit/reference/basic/pause)
|
||||
* **fade in** : [read more...](/microbit/reference/led/fade-in)
|
||||
|
||||
## Resources
|
||||
|
||||
* Activity: [tutorial](/microbit/lessons/glowing-sword/tutorial)
|
||||
* Activity: [quiz](/microbit/lessons/glowing-sword/quiz)
|
||||
* Extended Activity: [challenges](/microbit/lessons/glowing-sword/challenges)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to plot an image
|
||||
* learn how to gradually decrease the LED screen brightness until the LED lights are turned off
|
||||
* pause your code for the specified number of milliseconds
|
||||
* learn how to gradually increase the LED screen brightness until the LED lights are turned on
|
||||
|
||||
## Links to the National Curriculum Programmes of Study for Computing
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* Uses diagrams to express solutions.(AB)
|
||||
* Represents solutions using a structured notation (AL) (AB)
|
||||
|
||||
#### Programming & Development
|
||||
|
||||
* Creates programs that implement algorithms to achieve given goals (AL)
|
||||
* Selects the appropriate data types(AL) (AB)
|
||||
|
||||
#### Information Technology
|
||||
|
||||
* Collects, organizes, 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)
|
||||
* Recognises ethical issues surrounding the application of information technology beyond school.
|
||||
|
||||
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation
|
||||
|
||||
## Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [tutorial](/microbit/lessons/glowing-sword/tutorial)
|
||||
* [quiz](/microbit/lessons/lucky-7/quiz)
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/glowing-sword/challenges)
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/glowing-sword/challenges)
|
||||
|
||||
## Intended follow on
|
||||
|
||||
Publish script to the classroom.
|
||||
|
63
docs/reference/js/lessons/glowing-sword/activity.md
Normal file
63
docs/reference/js/lessons/glowing-sword/activity.md
Normal file
@ -0,0 +1,63 @@
|
||||
# glowing sword activity
|
||||
|
||||
Make glowing sword. #docs #microbit
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
### @video td/videos/glowing-sword-0
|
||||
|
||||
In this activity, we will learn how to fade in and out the screen to create a glowing animation. Let's get started!
|
||||
|
||||
### ~
|
||||
|
||||
Let's start by adding the code to display an image. Use `basic->plot image` to draw your favorite image.
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`) // ***
|
||||
```
|
||||
|
||||
We can control the brightness of the LED screen with code. That's just what we need to create a **glowing** animation: first we **fade out**, then **fade in**. Add a new line of code to **fade out** the screen.
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`)
|
||||
led.fadeOut(700) // ***
|
||||
```
|
||||
|
||||
Run your script to make sure it works as expected then add another line of code to **fade in** the screen.
|
||||
|
||||
```
|
||||
led.fadeIn(700)
|
||||
```
|
||||
|
||||
Finally, add a `basic->forever` loop and move the fade out and fade in code into the forever to repeat the glow pattern.
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`)
|
||||
led.fadeOut(700) // ***
|
||||
led.fadeIn(700) // ***
|
||||
```
|
||||
|
||||
### ~avatar boothing
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/microbit/lessons/glowing-sword/challenges)!
|
||||
|
||||
### ~
|
||||
|
62
docs/reference/js/lessons/glowing-sword/challenges.md
Normal file
62
docs/reference/js/lessons/glowing-sword/challenges.md
Normal file
@ -0,0 +1,62 @@
|
||||
# glowing sword challenges
|
||||
|
||||
Coding challenges for the glowing sword tutorial. #docs
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the [glowing sword](/microbit/lessons/glowing-sword/activity) activity and your code will look like this:
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`)
|
||||
led.fadeOut(700)
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Now, let's add `basic->pause(1000)` after the fade in so that there will be a 1000 millisecond (1 second) delay after the fade out.
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`)
|
||||
led.fadeOut(700)
|
||||
basic.pause(1000) // ***
|
||||
```
|
||||
|
||||
* `run main` the code to see if it works as expected.
|
||||
|
||||
### Challenge 2
|
||||
|
||||
### @video td/videos/glowing-sword-2
|
||||
|
||||
After the pause, let's add `led->fade in(2000)` so that we can create a glowing effect.
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`)
|
||||
led.fadeOut(700)
|
||||
basic.pause(1000)
|
||||
led.fadeIn(2000) // ***
|
||||
```
|
||||
|
||||
* `run main` the code to see if it works as expected.
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Now add another `basic->pause(1000)` and `led->fade out(900)` so that the sword can fade out again.
|
||||
|
48
docs/reference/js/lessons/glowing-sword/quiz-answers.md
Normal file
48
docs/reference/js/lessons/glowing-sword/quiz-answers.md
Normal file
@ -0,0 +1,48 @@
|
||||
# glowing sword quiz answers
|
||||
|
||||
The answers for the glowing sword quiz. #LED #image #fade #docs
|
||||
|
||||
This is the answer key for the [glowing sword quiz](/microbit/lessons/glowing-sword/quiz).
|
||||
|
||||
## 1. What is "fade out" ?
|
||||
|
||||
Fade out is a method that gradually decreases the LED screen brightness until the LED lights are turned off.
|
||||
|
||||
## 2. Consider the following code
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`)
|
||||
led.fadeOut(700)
|
||||
```
|
||||
|
||||
Rewrite the second line of code to decrease the speed of the fade out for the longest amount of time (Hint: 1000 milliseconds is longest amount of time for a fade out).
|
||||
|
||||
<br/>
|
||||
|
||||
led->fade out(1000)
|
||||
|
||||
## 4. Consider the following code
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`)
|
||||
led.fadeOut(1000)
|
||||
```
|
||||
|
||||
What will cause the image to fade back in twice as fast as it faded out?
|
||||
|
||||
<br/>
|
||||
|
||||
led->fade in(500)
|
||||
|
46
docs/reference/js/lessons/glowing-sword/quiz.md
Normal file
46
docs/reference/js/lessons/glowing-sword/quiz.md
Normal file
@ -0,0 +1,46 @@
|
||||
# glowing sword quiz
|
||||
|
||||
make a glowing sword. #LED #image #fade #docs
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [glowing sword tutorial](/microbit/lessons/glowing-sword/tutorial)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Describe what "led -> fade out" does?
|
||||
|
||||
<br />
|
||||
|
||||
## 2. Rewrite the second line of code to decrease the speed of the fade out for the longest amount of time Hint: 1000 milliseconds is longest amount of time for a fade out.
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`)
|
||||
led.fadeOut(700)
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. What will cause the image to fade back in twice as fast as it faded out?
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`)
|
||||
led.fadeOut(1000)
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
84
docs/reference/js/lessons/guess-the-number.md
Normal file
84
docs/reference/js/lessons/guess-the-number.md
Normal file
@ -0,0 +1,84 @@
|
||||
# guess the number lesson
|
||||
|
||||
Learn to create a random number with input from button A. #input #screen #math #docs
|
||||
|
||||
### @video td/videos/guess-the-number-0
|
||||
|
||||
## Topic
|
||||
|
||||
Math - Random Numbers
|
||||
|
||||
## Quick links
|
||||
|
||||
* [activity](/microbit/lessons/guess-the-number/activity)
|
||||
* [challenges](/microbit/lessons/guess-the-number/challenges)
|
||||
* [quiz](/microbit/lessons/guess-the-number/quiz)
|
||||
* [quiz answers](/microbit/lessons/guess-the-number/quiz-answers)
|
||||
* [tutorial](/microbit/lessons/guess-the-number/tutorial)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to create numbers randomly by using the input of the BBC micro:bit. We will be learning how to create random numbers with input using a local variable as well as simple commands, such as math->random, and show number.
|
||||
|
||||
## Documentation
|
||||
|
||||
* **on button pressed**: [read more...](/microbit/reference/input/on-button-pressed)
|
||||
* **local variable **: [read more...](/microbit/reference/variables/var)
|
||||
* **assignment operator**: [read more...](/microbit/reference/variables/assign)
|
||||
* **show number**: [read more...](/microbit/reference/basic/show-number)
|
||||
* **random numbers**: [read more...](/microbit/js/math)
|
||||
* **clear screen**: [read more...](/microbit/reference/basic/clear-screen)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to run code when an input button is pressed
|
||||
* learn how a variable is a place where you can store data
|
||||
* learn how to set the value of a local variable
|
||||
* learn how to returns a random number
|
||||
* learn how to show a number on the LED screen, one digit at a time (scrolling left to right)
|
||||
* learn how to turn off all the LED lights on the LED screen
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* 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)
|
||||
* Declares and assigns variables.(AB)
|
||||
|
||||
#### 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: 20 min.
|
||||
* [activity](/microbit/lessons/guess-the-number/activity)
|
||||
* [tutorial](/microbit/lessons/guess-the-number/tutorial)
|
||||
* [quiz](/microbit/lessons/guess-the-number/quiz)
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/guess-the-number/challenges)
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/guess-the-number/challenges)
|
||||
|
44
docs/reference/js/lessons/guess-the-number/activity.md
Normal file
44
docs/reference/js/lessons/guess-the-number/activity.md
Normal file
@ -0,0 +1,44 @@
|
||||
# guess the number activity
|
||||
|
||||
guess the number with math random. #microbit #docs
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
### @video td/videos/guess-the-number-0
|
||||
|
||||
Welcome! This tutorial will help you create a guess the number game! Let's get started!
|
||||
|
||||
### ~
|
||||
|
||||
To create a new script, go to the [Create Code](/microbit/create-code) page and tap New Project under **Touch Develop**.
|
||||
|
||||
Add an event handler when button `A` is pressed.
|
||||
|
||||
```
|
||||
input.onButtonPressed("A", () => {
|
||||
})
|
||||
```
|
||||
|
||||
Create a local variable of type number `x` and set it to a random number using `math->random`. `math->random(10)` generates a random number between `0` and `10` **excluded**.
|
||||
|
||||
```
|
||||
input.onButtonPressed("A", () => {
|
||||
let x = Math.random(10)
|
||||
})
|
||||
```
|
||||
|
||||
Show the random number on the screen.
|
||||
|
||||
```
|
||||
input.onButtonPressed("A", () => {
|
||||
let x1 = Math.random(10)
|
||||
basic.showNumber(x1, 150)
|
||||
})
|
||||
```
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/microbit/lessons/guess-the-number/challenges)!
|
||||
|
||||
### ~
|
||||
|
39
docs/reference/js/lessons/guess-the-number/challenges.md
Normal file
39
docs/reference/js/lessons/guess-the-number/challenges.md
Normal file
@ -0,0 +1,39 @@
|
||||
# guess the number challenges
|
||||
|
||||
Coding challenges for the guess the number tutorial. #docs
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following guided tutorial:
|
||||
|
||||
* [tutorial](/microbit/lessons/guess-the-number/tutorial)
|
||||
|
||||
At the end of the tutorial, click `keep editing`. Your code should look like this:
|
||||
|
||||
```
|
||||
input.onButtonPressed("A", () => {
|
||||
let x = Math.random(10)
|
||||
basic.showNumber(x, 150)
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
### @video td/videos/guess-the-number-2
|
||||
|
||||
When button `B` is pressed, we want to clear the screen. This will make it so users can play your game over and over again! Add an event handler to handle this case.
|
||||
|
||||
```
|
||||
input.onButtonPressed("A", () => {
|
||||
let x1 = Math.random(10)
|
||||
basic.showNumber(x1, 150)
|
||||
})
|
||||
input.onButtonPressed("B", () => {
|
||||
basic.clearScreen() // ***
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Show an animation when you clear the screen! Choose what animation makes most sense to you. Be creative!
|
||||
|
99
docs/reference/js/lessons/guess-the-number/lesson-plan.md
Normal file
99
docs/reference/js/lessons/guess-the-number/lesson-plan.md
Normal file
@ -0,0 +1,99 @@
|
||||
# guess the number lesson plan
|
||||
|
||||
Learn how to create a random number with input from button A. #input #screen #math #docs
|
||||
|
||||
### @video vimeo/134121077
|
||||
|
||||
## Topic
|
||||
|
||||
Input - Random Numbers
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to create numbers randomly by using the input of the BBC micro:bit. We will be learning how to create random numbers with input using a local variable as well as simple commands, such as math->random, and show number.
|
||||
|
||||
## 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 Forever. Forever will repeats code in the background forever.
|
||||
|
||||
**Command:** An instruction for the computer to execute, written in a particular programming language.**
|
||||
|
||||
**QuickStart Computing Glossary
|
||||
|
||||
## Documentation
|
||||
|
||||
* **local variables**: [read more...](/microbit/reference/variables/var)
|
||||
* **math**: [read more...](/microbit/js/math)
|
||||
* **on button pressed**: [read more...](/microbit/reference/input/on-button-pressed)
|
||||
|
||||
## Resources
|
||||
|
||||
* Activity: [tutorial](/microbit/lessons/guess-the-number/tutorial)
|
||||
* Activity: [quiz](/microbit/lessons/guess-the-number/quiz)
|
||||
* Extended Activity: [challenges](/microbit/lessons/guess-the-number/challenges)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to create a global variable
|
||||
* learn how a rotating animation
|
||||
* learn how to repeat the animation
|
||||
|
||||
## Links to the National Curriculum Programmes of Study for Computing
|
||||
|
||||
## Assessment
|
||||
|
||||
### Progression Pathways
|
||||
|
||||
### Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* 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)
|
||||
* Declares and assigns variables.(AB)
|
||||
|
||||
#### 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: 20 min.
|
||||
* [tutorial](/microbit/lessons/guess-the-number/tutorial)
|
||||
* [quiz](/microbit/lessons/guess-the-number/quiz)
|
||||
* assessment opportunities: forever, plot, pause, clear screen
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/guess-the-number/challenges)
|
||||
* assessment opportunities: loops, plot, pause, clear screen
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/guess-the-number/challenges)
|
||||
|
||||
## Intended follow on
|
||||
|
||||
Publish script to the classroom.
|
||||
|
39
docs/reference/js/lessons/guess-the-number/quiz-answers.md
Normal file
39
docs/reference/js/lessons/guess-the-number/quiz-answers.md
Normal file
@ -0,0 +1,39 @@
|
||||
# guess the number quiz answers
|
||||
|
||||
Learn how to generate a random number on the micro:bit. #math #random #docs
|
||||
|
||||
This is the answer key for the [guess the number quiz](/microbit/lessons/guess-the-number/quiz).
|
||||
|
||||
## 1. What is on button pressed?
|
||||
|
||||
Answers may vary. Generally, on button pressed run code when an input button is pressed. The micro:bit has two input buttons: A and B.
|
||||
|
||||
## 2. Consider the following directions
|
||||
|
||||
Write the line of code that creates a condition when the BBC micro:bit button A is pressed.
|
||||
|
||||
```
|
||||
input.onButtonPressed("A", () => {
|
||||
})
|
||||
```
|
||||
|
||||
## 3. Consider the following directions
|
||||
|
||||
Write the line of code that creates a **local variable** and a **random number**.
|
||||
|
||||
```
|
||||
let randomNumber = Math.random(10)
|
||||
```
|
||||
|
||||
## 4. Consider the following code
|
||||
|
||||
```
|
||||
randomNumber = Math.random(10)
|
||||
```
|
||||
|
||||
If the rectangle below represents the BBC micro:bit, shade the areas that will be displayed. Explain why that particular area is shaded.
|
||||
|
||||

|
||||
|
||||
The random number generator will return a number from 0 to the limit. However, not including the limit unless the limit is 0. So you can place an X to represent any single digit number.
|
||||
|
35
docs/reference/js/lessons/guess-the-number/quiz.md
Normal file
35
docs/reference/js/lessons/guess-the-number/quiz.md
Normal file
@ -0,0 +1,35 @@
|
||||
# guess the number quiz
|
||||
|
||||
Learn how to generate a random number on the micro:bit. #math #random #docs
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [guess the number tutorial](/microbit/lessons/guess-the-number/tutorial).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Describe what "input -> on button pressed" does?
|
||||
|
||||
<br />
|
||||
|
||||
## 2. Write the line of code that creates a condition for on button A pressed.
|
||||
|
||||
<br />
|
||||
|
||||
## 3. Write the line of code that creates a `local variable` called `randomNumber` and will return a number from 0 to a limit of 10.
|
||||
|
||||
<br />
|
||||
|
||||
## 4. Draw the area that could be lit based on the code below. Explain why you chose to draw that number.
|
||||
|
||||
```
|
||||
let randomNumber = Math.random(10)
|
||||
basic.showNumber(randomNumber, 150)
|
||||
```
|
||||
|
||||

|
||||
|
||||
<br />
|
||||
|
24
docs/reference/js/lessons/hack-your-headphones.md
Normal file
24
docs/reference/js/lessons/hack-your-headphones.md
Normal file
@ -0,0 +1,24 @@
|
||||
# hack your headphones lesson
|
||||
|
||||
display beautiful images on the BBC micro:bit #var #pause #docs
|
||||
|
||||
## Topic
|
||||
|
||||
Hack your headphone
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [activity](/microbit/lessons/hack-your-headphones/activity)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to convert your BBC micro:bit into a music player using pins P0 and GND, headphones (or speakers), as well as crocodile clips (or spring clips).
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to setup the BBC micro:bit with headphones to play music
|
||||
|
56
docs/reference/js/lessons/hack-your-headphones/activity.md
Normal file
56
docs/reference/js/lessons/hack-your-headphones/activity.md
Normal file
@ -0,0 +1,56 @@
|
||||
# hack your headphones activity
|
||||
|
||||
hack your headphones #microbit #docs
|
||||
|
||||
# BBC micro:bit music
|
||||
|
||||

|
||||
|
||||
In this project, you will build your own music player BBC micro:bit from headphones. Project duration: 15 minutes.
|
||||
|
||||
## Materials
|
||||
|
||||
* BBC micro:bit, battery holder and 2 AAA batteries
|
||||
* Headphones
|
||||
* Crocodile clips
|
||||
|
||||
## Steps
|
||||
|
||||
### Step 1
|
||||
|
||||

|
||||
|
||||
Using the 1st crocodile clip, connect the end of the crocodile clip onto GND pin on the BBC micro:bit.
|
||||
|
||||
### Step 2
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
Using the 2nd crocodile clip, connect the end of the crocodile clip onto the 0 pin on the BBC micro:bit.
|
||||
|
||||
### Step 3
|
||||
|
||||

|
||||
|
||||
Using the 1st crocodile clip, connect the second end of the crocodile clip onto based of the headphone jack. The base of your headphone jack is considered the ground so it is connected to the GND of the BBC micro:bit.
|
||||
|
||||
### Step 4
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
Using the 2nd crocodile clip, connect the second end of the crocodile clip onto the tip of the headphone jack. The tip of your headphone jack feeds into the right speaker on the headphone. You connect from the BBC micro:bit pin 0 to the tip of the right side of your headphone. Use the tip of the headphone jack to play sounds.
|
||||
|
||||
### Step 5
|
||||
|
||||

|
||||
|
||||
You hacked your headphones!
|
||||
|
||||
### Step 6
|
||||
|
||||
Connect your BBC micro:bit to your computer using your USB cable and run the [happy birthday](/microbit/dnnzgd) script on it. Press the reset button to restart your music player!
|
||||
|
130
docs/reference/js/lessons/headbands.md
Normal file
130
docs/reference/js/lessons/headbands.md
Normal file
@ -0,0 +1,130 @@
|
||||
# headbands lesson
|
||||
|
||||
create a charades game that can be played with your friends #data #string #collection #at #Boolean #on-logo-down #on-logo-up #running-time #string #number #docs
|
||||
|
||||
## Topic
|
||||
|
||||
Collection
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [tutorial](/microbit/lessons/headbands/tutorial)
|
||||
* [quiz](/microbit/lessons/headbands/quiz)
|
||||
* [quiz answers](/microbit/lessons/headbands/quiz-answers)
|
||||
* [challenges](/microbit/lessons/headbands/challenges)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to create a charades game with **collections**, ` create -> Collection of` , to store and retrieve data . We will be learning how to create a charades game using global variables, collection of string, add, Boolean, on logo down, on logo up, forever loop, if statements, running time as well as simple commands, such as show string and show number.
|
||||
|
||||
## What the teacher needs to know
|
||||
|
||||
* Algorithm: An unambiguous set of rules or a precise step-bystep guide to solve a problem or achieve a particular objective.
|
||||
* Command: An instruction for the computer to execute, written in a particular programming language.
|
||||
* Data: A structured set of numbers, possibly representing digitised text, images, sound or video, which can be processed or transmitted by a computer, also used for numerical (quantitative) information.
|
||||
* Decomposing: The process through which problems or systems are broken down into their component parts, each of which may then be considered separately.
|
||||
* Input: Data provided to a computer system, such as via a keyboard, mouse, microphone, camera or physical sensors.
|
||||
* Output: The information produced by a computer system for its user, typically on a screen, through speakers or on a printer, but possibly through the control of motors in physical systems.
|
||||
* Programmable toys: Robots designed for children to use, accepting input, storing short sequences of simple instructions and moving according to this stored program.
|
||||
* 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.
|
||||
* Script: A computer program typically executed one line at a time through an interpreter, such as the instructions for a Scratch character.
|
||||
* Selection: A programming construct in which one section of code or another is executed depending on whether a particular condition is met.
|
||||
* Sequence: To place program instructions in order, with each executed one after the other.
|
||||
* Simulation: Using a computer to model the state and behaviour of real-world (or imaginary) systems, including physical or social systems; an integral part of most computer games.
|
||||
* Variables: A way in which computer programs can store, retrieve or change data, such as a score, the time left, or the user’s name.
|
||||
|
||||
**QuickStart Computing Glossary
|
||||
|
||||
## Documentation
|
||||
|
||||
* **collection**
|
||||
* **global variables** : [read more...](/microbit/js/data)
|
||||
* **Boolean** : [read more...](/microbit/reference/types/boolean)
|
||||
* **on logo up** [read more...](/microbit/functions/on-logo-up)
|
||||
* **on screen down** [read more...](/microbit/functions/on-screen-down)
|
||||
* **on screen up** [read more...](/microbit/functions/on-screen-up)
|
||||
* **show string** : [read more...](/microbit/reference/basic/show-string)
|
||||
* **game library** : [read more...](/microbit/js/game-library)
|
||||
|
||||
## Resources
|
||||
|
||||
* Activity: [tutorial](/microbit/lessons/headbands/tutorial)
|
||||
* Activity: [quiz](/microbit/lessons/headbands/quiz)
|
||||
* Extended Activity: [challenges](/microbit/lessons/headbands/challenges)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how a collection is a group of variables of the same type stored together
|
||||
* learn how to create a global variable as a place where you can store data so that you can use it later in your code, accessible across functions and in nested code blocks
|
||||
* learn how to repeat code in the background forever
|
||||
* learn how to learn how to conditionally run code depending on whether a condition is true or not
|
||||
* learn how to run code when the BBC micro:bit is oriented perpendicular to the floor with the logo down
|
||||
* learn how to get the number of milliseconds elapsed since the script began
|
||||
* learn how to show a string on the BBC micro:bit screen
|
||||
* learn how to show a number of the BBC micro:bit screen
|
||||
|
||||
## Links to the National Curriculum Programmes of Study for Computing
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* Designs solutions (algorithms) that use repetition and two-way selection, ie if, then and else.(AL)
|
||||
* Uses logical reasoning to predict outputs, showing an awareness of inputs (AL)
|
||||
* Recognises that different solutions exist for the same problem (AL) (AB) 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)
|
||||
* Declares and assigns variables(AB)
|
||||
* Understands the difference between, and appropriately uses if and if, then and else statements(AL)
|
||||
* Uses a variable and relational operators within a loop to govern termination (AL) (GE)
|
||||
* Has practical experience of a high-level textual language, including using standard libraries when programming(AB) (AL)
|
||||
* Uses a range of operators and expressions e.g. Boolean, and applies them in the context of program control. (AL)
|
||||
* Selects the appropriate data types(AL) (AB
|
||||
|
||||
#### Data & Data Representation
|
||||
|
||||
* Understands the difference between data and information(AB)
|
||||
* Performs more complex searches for information e.g. using Boolean and relational operators(AL) (GE) (EV)
|
||||
|
||||
#### Hardware & Processing
|
||||
|
||||
* Knows that computers collect data from various input devices, including sensors and application software (AB)
|
||||
|
||||
#### Communication Networks
|
||||
|
||||
* Demonstrates responsible use of technologies and online services, and knows a range of ways to report concerns Understands how search engines rank search results (AL)
|
||||
|
||||
#### Information Technology
|
||||
|
||||
* Collects, organizes, 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)
|
||||
* Uses criteria to evaluate the quality of solutions, can identify improvements making some refinements to the solution, and future solutions (EV)
|
||||
|
||||
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation
|
||||
|
||||
## Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [tutorial](/microbit/lessons/headbands/tutorial)
|
||||
* [quiz](/microbit/lessons/headbands/quiz)
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/headbands/challenges)
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/headbands/challenges)
|
||||
|
||||
## Intended follow on
|
||||
|
||||
Publish script to the classroom.
|
||||
|
74
docs/reference/js/lessons/headbands/challenges.md
Normal file
74
docs/reference/js/lessons/headbands/challenges.md
Normal file
@ -0,0 +1,74 @@
|
||||
# headbands challenges
|
||||
|
||||
These challenges will teach you how to create a fun charades game to play with your friends. #docs
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following guided tutorial:
|
||||
|
||||
* [tutorial](/microbit/lessons/headbands/tutorial)
|
||||
|
||||
At the tend of the tutorial, click `keep editing`. Your code should look like this:
|
||||
|
||||
```
|
||||
coll = (<string[]>[])
|
||||
coll.push("puppy")
|
||||
coll.push("clock")
|
||||
coll.push("night")
|
||||
coll.push("cat")
|
||||
coll.push("cow")
|
||||
input.onLogoUp(() => {
|
||||
let index = Math.random(coll.length)
|
||||
let word = coll[index]
|
||||
basic.showString(word, 150)
|
||||
})
|
||||
input.onScreenDown(() => {
|
||||
game.addScore(1)
|
||||
})
|
||||
game.startCountdown(30000)
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Let's add more words for the player to act out! But first, we need to increase the time in one round to give the player more time get through all the words. Let's change the `game->start countdown` statement.
|
||||
|
||||
```
|
||||
// **. . .**
|
||||
game.startCountdown(60000) // ***
|
||||
```
|
||||
|
||||
* Run your code to see if it works as expected
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Now let's add 5 more words to our list of charade words. Right above the the line `word:=coll->at(index)` add 5 lines that say `coll->add("")`. In this example, we will add the words **bicycle, telephone, sun, car, and ant** but you can add whatever words you like.
|
||||
|
||||
```
|
||||
// . . .
|
||||
coll.push("puppy")
|
||||
coll.push("clock")
|
||||
coll.push("night")
|
||||
coll.push("cat")
|
||||
coll.push("cow")
|
||||
coll.push("bicycle") // ***
|
||||
coll.push("telephone") // ***
|
||||
coll.push("sun") // ***
|
||||
coll.push("car") // ***
|
||||
coll.push("ant") // ***
|
||||
// . . .
|
||||
```
|
||||
|
||||
* Run your code to see if it works as expected.
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Remove a life using `game->remove life` when the screen is down using the `input->on screen down` event.
|
||||
|
||||
### Challenge 4
|
||||
|
||||
The collection has a function `random` that returns a random element. Update your code to use this function instead of using `math->random`.
|
||||
|
||||
### Challenge 5!
|
||||
|
||||
Play the game and try guessing all these words in less than 2 minutes!
|
||||
|
78
docs/reference/js/lessons/headbands/quiz-answers.md
Normal file
78
docs/reference/js/lessons/headbands/quiz-answers.md
Normal file
@ -0,0 +1,78 @@
|
||||
# headbands quiz answers
|
||||
|
||||
create a charades game with a collection of strings #offset #screen #variables #docs
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [headbands tutorial](/microbit/lessons/headbands/tutorial).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. What is the meaning of the term 'collection' in programming? What is a 'collection' of strings?
|
||||
|
||||
<br/>
|
||||
|
||||
A 'collection' is a group of variables of the same type stored together. A 'collection' of strings is a group of strings stored together.
|
||||
|
||||
## 2. Consider the following lines of code.
|
||||
|
||||
```
|
||||
coll = (<string[]>[])
|
||||
coll.push("puppy")
|
||||
coll.push("clock")
|
||||
```
|
||||
|
||||
Write the line of code that will display the string "puppy" using `data->coll`.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
basic.showString(coll[0], 150)
|
||||
```
|
||||
|
||||
## 3. Consider the following lines of code.
|
||||
|
||||
```
|
||||
coll = (<string[]>[])
|
||||
coll.push("puppy")
|
||||
coll.push("clock")
|
||||
coll.push("cat")
|
||||
```
|
||||
|
||||
Write the line of code that will display the string "cat" using `data->coll`.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
basic.showString(coll[2], 150)
|
||||
```
|
||||
|
||||
## 4. Consider the following line of code.
|
||||
|
||||
```
|
||||
coll = (<string[]>[])
|
||||
```
|
||||
|
||||
Write the five (5) lines of code that will add the following five words to `data->coll`: puppy, clock, night, cat, cow.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
coll.push("puppy")
|
||||
coll.push("clock")
|
||||
coll.push("night")
|
||||
coll.push("cat")
|
||||
coll.push("cow")
|
||||
```
|
||||
|
||||
## 5. Write the code to get a string from the collection at a random position.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
let index = Math.random(coll.length)
|
||||
let word = coll[index]
|
||||
```
|
||||
|
63
docs/reference/js/lessons/headbands/quiz.md
Normal file
63
docs/reference/js/lessons/headbands/quiz.md
Normal file
@ -0,0 +1,63 @@
|
||||
# headbands quiz
|
||||
|
||||
create a charades game with a collection of strings #offset #screen #variables #docs
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [headbands tutorial](/microbit/lessons/headbands/tutorial).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. What is the meaning of the term 'collection' in programming? What is a 'collection' of strings?
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Write the line of code that will display the string "puppy" using "data->coll".
|
||||
|
||||
```
|
||||
coll = (<string[]>[])
|
||||
coll.push("puppy")
|
||||
coll.push("clock")
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Write the line of code that will display the string "cat" using `"data->coll".
|
||||
|
||||
```
|
||||
coll = (<string[]>[])
|
||||
coll.push("puppy")
|
||||
coll.push("clock")
|
||||
coll.push("cat")
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
||||
## 4. Write the five (5) lines of code that will add the following five words to `data->coll`: puppy, clock, night, cat, cow.
|
||||
|
||||
```
|
||||
coll = (<string[]>[])
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
## 5. Write the code to get a string from the collection at a random position.
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
|
108
docs/reference/js/lessons/jailbreak.md
Normal file
108
docs/reference/js/lessons/jailbreak.md
Normal file
@ -0,0 +1,108 @@
|
||||
# jailbreak lesson
|
||||
|
||||
break out of a counting loop by pressing button "A" #button #while #if #Boolean #pause #string #plot #break #docs
|
||||
|
||||
### @video td/videos/jailbreak-0
|
||||
|
||||
## Topic
|
||||
|
||||
Break
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [tutorial](/microbit/lessons/jailbreak/tutorial)
|
||||
* [quiz](/microbit/lessons/jailbreak/quiz)
|
||||
* [quiz answers](/microbit/lessons/jailbreak/quiz-answers)
|
||||
* [challenges](/microbit/lessons/jailbreak/challenges)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to create a **break**, `break` to exit a while or for loop before the loop is complete. We will be learning how to create a break using global variables, Boolean, If (conditionals), a While Loop as well as simple commands, such as show string, plot image, show number, and pause.
|
||||
|
||||
## Documentation
|
||||
|
||||
* **Global Variable** : [read more...](/microbit/js/data)
|
||||
* **Boolean** : [read more...](/microbit/reference/types/boolean)
|
||||
* **On Button Pressed** : [read more...](/microbit/reference/input/on-button-pressed)
|
||||
* **While Loop** : [read more...](/microbit/js/while)
|
||||
* **Break** : [read more...](/microbit/js/break)
|
||||
* **If (Conditional)** : [read more...](/microbit/reference/logic/if)
|
||||
* **Show String** : [read more...](/microbit/reference/basic/show-string)
|
||||
* **Plot Image ** : [read more...](/microbit/reference/led/plot-image)
|
||||
* **Show Number** : [read more...](/microbit/reference/basic/show-number)
|
||||
* **Pause** : [read more...](/microbit/reference/basic/pause)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to create global variables to store data so that you can use it later in your code, functions, and in nested code blocks
|
||||
* learn how to use the variables to declare a new local Boolean variable that will have one of two possible values: true or false
|
||||
* learn how to run code when an input button is pressed
|
||||
* learn how to repeat code while a condition is true
|
||||
* learn how to exit a while loop before the loop is complete
|
||||
* learn how to conditionally run code depending on whether a condition is true or not
|
||||
* learn how to show a string on the LED screen one character at a time
|
||||
* learn how to turn on LED lights on the LED screen
|
||||
* learn how to show a number on the LED screen, one digit at a time
|
||||
* learn how to pause your code for the specified number of milliseconds
|
||||
|
||||
## Progression Pathways / Computational Thinking Framework
|
||||
|
||||
#### Algorithms
|
||||
|
||||
* Designs solutions (algorithms) that use repetition and two-way selection, ie if, then and else.(AL)
|
||||
* Uses diagrams to express solutions.(AB)
|
||||
* Uses logical reasoning to predict outputs, showing an awareness of inputs (AL)
|
||||
* Recognises that different solutions exist for the same problem (AL) (AB) Understands that iteration is the repetition of a process such as a loop (AL)
|
||||
* Recognises that different algorithms exist for the same problem (AL) (GE)
|
||||
* Represents solutions using a structured notation (AL) (AB)
|
||||
|
||||
#### Programming & Development
|
||||
|
||||
* Creates programs that implement algorithms to achieve given goals (AL)
|
||||
* Declares and assigns variables(AB)
|
||||
* Uses post-tested loop e.g.‘until’,and a sequence of selection statements in programs,including an if,then and else statement(AL)
|
||||
* Understands the difference between, and appropriately uses if and if, then and else statements(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)
|
||||
* Selects the appropriate data types(AL) (AB
|
||||
|
||||
#### Data & Data Representation
|
||||
|
||||
* Performs more complex searches for information e.g. using Boolean and relational operators(AL) (GE) (EV)
|
||||
* Defines data types: real numbers and Boolean (AB)
|
||||
|
||||
#### Hardware & Processing
|
||||
|
||||
* Knows that computers collect data from various input devices, including sensors and application software (AB)
|
||||
|
||||
#### Communication Networks
|
||||
|
||||
* Demonstrates responsible use of technologies and online services, and knows a range of ways to report concerns Understands how search engines rank search results (AL)
|
||||
|
||||
#### Information Technology
|
||||
|
||||
* Collects, organizes, 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)
|
||||
* Recognises ethical issues surrounding the application of information technology beyond school.
|
||||
|
||||
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation
|
||||
|
||||
## Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [tutorial](/microbit/lessons/jailbreak/tutorial)
|
||||
* [quiz](/microbit/lessons/jailbreak/quiz)
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/jailbreak/challenges)
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/jailbreak/challenges)
|
||||
|
104
docs/reference/js/lessons/jailbreak/challenges.md
Normal file
104
docs/reference/js/lessons/jailbreak/challenges.md
Normal file
@ -0,0 +1,104 @@
|
||||
# jailbreak challenges
|
||||
|
||||
Coding challenges for the jailbreak tutorial.#docs
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following guided tutorial:
|
||||
|
||||
* [tutorial](/microbit/lessons/jailbreak/tutorial)
|
||||
|
||||
At the end of the tutorial, click `keep editing`. Your code should look like this:
|
||||
|
||||
```
|
||||
count = 0
|
||||
shouldBreak = false
|
||||
input.onButtonPressed("A", () => {
|
||||
shouldBreak = true
|
||||
})
|
||||
while (true) {
|
||||
if (shouldBreak) {
|
||||
basic.showString("I'M OUT!", 150)
|
||||
basic.plotImage(`
|
||||
. # . # .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
break
|
||||
}
|
||||
count = count + 1
|
||||
basic.showNumber(count, 150)
|
||||
basic.pause(1000)
|
||||
}
|
||||
```
|
||||
|
||||
**Challenge 1**
|
||||
|
||||
Try to remove the `break` in the `if` loop. What problem does this create?
|
||||
|
||||
**Challenge 2**
|
||||
|
||||
Now let's resume the timer again once button `B` is pressed! To do so, begin by creating a condition to know when button `B` is pressed.
|
||||
|
||||
```
|
||||
// **. . .**
|
||||
while (true) {
|
||||
if (shouldBreak) {
|
||||
basic.showString("I'M OUT!", 150)
|
||||
basic.plotImage(`
|
||||
. # . # .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
break
|
||||
}
|
||||
count = count + 1
|
||||
basic.showNumber(count, 150)
|
||||
basic.pause(1000)
|
||||
}
|
||||
input.onButtonPressed("B", () => {
|
||||
}) // ***
|
||||
```
|
||||
|
||||
Next, set `should break` back to false to indicate we want to run the `while` loop again.
|
||||
|
||||
```
|
||||
// **. . .**
|
||||
input.onButtonPressed("B", () => {
|
||||
shouldBreak = false // ***
|
||||
})
|
||||
```
|
||||
|
||||
And now copy the code from the previous while loop into the condition of `input->on button pressed("B")`. This will resume the counter.
|
||||
|
||||
```
|
||||
// **. . .**
|
||||
input.onButtonPressed("B", () => {
|
||||
shouldBreak = false
|
||||
while (true) {
|
||||
if (shouldBreak) {
|
||||
basic.showString("I'M OUT!", 150) // ***
|
||||
basic.plotImage(`
|
||||
. # . # .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`) // ***
|
||||
break // ***
|
||||
}
|
||||
count = count + 1 // ***
|
||||
basic.showNumber(count, 150) // ***
|
||||
basic.pause(1000) // ***
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
**Challenge 3**
|
||||
|
||||
Notice that the two `while` loops are identical. Clean up this redundancy in your code by creating another method and then placing the `while` loop in the method.
|
||||
|
46
docs/reference/js/lessons/jailbreak/quiz-answers.md
Normal file
46
docs/reference/js/lessons/jailbreak/quiz-answers.md
Normal file
@ -0,0 +1,46 @@
|
||||
# jailbreak quiz answers
|
||||
|
||||
break out of a counting loop by pressing button "A" #break #string #variables #docs
|
||||
|
||||
This is the answer key for the [jailbreak quiz](/microbit/lessons/jailbreak/quiz).
|
||||
|
||||
## 1. What does a 'break' statement do to a 'loop' ?
|
||||
|
||||
Exit a while or for loop before the loop is complete.
|
||||
|
||||
## 2. Consider the following directions
|
||||
|
||||
Write the line of code that will initialize a number `variable` to 0. Then create a second `variable` that tells us when we should `break` out of the loop. Set the `break` to false.
|
||||
|
||||
```
|
||||
count = 0
|
||||
shouldBreak = false
|
||||
```
|
||||
|
||||
## 3. Consider the following directions
|
||||
|
||||
Write the line of code to stop incrementing `count` when the button is pressed. (Hint: This will set `should break` to true).
|
||||
|
||||
```
|
||||
input.onButtonPressed("A", () => {
|
||||
shouldBreak = true
|
||||
})
|
||||
```
|
||||
|
||||
## 4. Consider the following directions
|
||||
|
||||
Add an `if` statement to determine whether or not we should break out of the loop. Then include the message "I'm Out!" and a smiley face **image** displayed. This will happen right before you `break` from the `while` loop. **Do not include the break **
|
||||
|
||||
```
|
||||
if (shouldBreak) {
|
||||
basic.showString("I'M OUT!", 150)
|
||||
images.createImage(`
|
||||
. # . # .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`).showImage(0)
|
||||
}
|
||||
```
|
||||
|
34
docs/reference/js/lessons/jailbreak/quiz.md
Normal file
34
docs/reference/js/lessons/jailbreak/quiz.md
Normal file
@ -0,0 +1,34 @@
|
||||
# jailbreak quiz
|
||||
|
||||
break out of a counting loop by pressing button "A" #break #string #variables #docs
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [jailbreak tutorial](/microbit/lessons/jailbreak/tutorial)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. What does a 'break' statement do to a 'loop' ?
|
||||
|
||||
## 2. Consider the following directions
|
||||
|
||||
Write the line of code that will initialize a number variable to 0. Then create a second variable that tells us when we should `break` out of the loop. Set the `break` to false.
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Consider the following directions
|
||||
|
||||
Write the line of code to stop incrementing `count` when the button is pressed. (Hint: This will set `should break` to true).
|
||||
|
||||
<br/>
|
||||
|
||||
## 4. Consider the following directions
|
||||
|
||||
Add an `if` statement to determine whether or not we should break out of the loop. Then include the message "I'm Out!" and a smiley face **image** displayed. This will happen right before you `break` from the `while` loop. **Do not include the break **
|
||||
|
||||
<br />
|
||||
|
||||
<br/>
|
||||
|
8
docs/reference/js/lessons/landslide.md
Normal file
8
docs/reference/js/lessons/landslide.md
Normal file
@ -0,0 +1,8 @@
|
||||
# landslide
|
||||
|
||||
Turn a LED on and off. #docs
|
||||
|
||||
Detect and show an image when the micro:bit falls.
|
||||
|
||||
* [tutorial](/microbit/lessons/landslide/tutorial)
|
||||
* [challenges](/microbit/lessons/landslide/challenges)
|
77
docs/reference/js/lessons/landslide/challenges.md
Normal file
77
docs/reference/js/lessons/landslide/challenges.md
Normal file
@ -0,0 +1,77 @@
|
||||
# landslide challenges
|
||||
|
||||
Coding challenges for the landslide tutorial. #onfall #docs
|
||||
|
||||
### ~avatar avatar fail
|
||||
|
||||
Don't drop me on the ground without protection! I'm very fragile. Ouch!
|
||||
|
||||
### ~
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the following guided tutorial:
|
||||
|
||||
* [tutorial](/microbit/lessons/landslide/tutorial)
|
||||
|
||||
At the end of the tutorial, click `keep editing`. Your code should look like this:
|
||||
|
||||
```
|
||||
input.onFall(() => {
|
||||
images.createImage(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
`).showImage(0) // ***
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Add a pause within `input->on fall` after displaying `!`. This will allow us to display another image in the next challenge.
|
||||
|
||||
```
|
||||
input.onFall(() => {
|
||||
images.createImage(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
`).showImage(0)
|
||||
basic.pause(2000) // ***
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Create and show an `X` image after the pause from Challenge 1.
|
||||
|
||||
```
|
||||
input.onFall(() => {
|
||||
images.createImage(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
`).showImage(0)
|
||||
basic.pause(2000)
|
||||
images.createImage(`
|
||||
# . . . #
|
||||
. # . # .
|
||||
. . # . .
|
||||
. # . # .
|
||||
# . . . #
|
||||
`).showImage(0) // ***
|
||||
})
|
||||
```
|
||||
|
||||
* `Run` the program to see if it works as expected.
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Now let's display a third image when the micro:bit falls! First, add `basic->pause(2000)` followed by another image of your choice. Be creative!
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user