merged changes
This commit is contained in:
49
docs/lessons/catch-the-egg-game.md
Normal file
49
docs/lessons/catch-the-egg-game.md
Normal file
@ -0,0 +1,49 @@
|
||||
# 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
|
||||
|
||||
* [activity](/microbit/lessons/catch-the-egg-game/activity)
|
||||
* [quiz](/microbit/lessons/catch-the-egg-game/quiz)
|
||||
* [quiz answers](/microbit/lessons/catch-the-egg-game/quiz-answers)
|
||||
|
||||
## 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 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
|
152
docs/lessons/catch-the-egg-game/activity.md
Normal file
152
docs/lessons/catch-the-egg-game/activity.md
Normal file
@ -0,0 +1,152 @@
|
||||
# catch the egg game challenges
|
||||
|
||||
Coding challenges for catch the egg game.
|
||||
|
||||
## Before we get started
|
||||
|
||||
Your starting code should look like this:
|
||||
|
||||
```blocks
|
||||
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(Dimension.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 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!
|
||||
|
||||
### ~
|
||||
|
||||
```blocks
|
||||
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 accX = input.acceleration(Dimension.X)
|
||||
basketX1 = 2 + Math.min(2, Math.max(-2, accX / 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 2
|
||||
|
||||
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.
|
||||
|
||||
### ~
|
||||
|
||||
```blocks
|
||||
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(Dimension.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 (game.score() %5 == 0) {
|
||||
}
|
||||
} else {
|
||||
game.removeLife(1)
|
||||
}
|
||||
}
|
||||
basic.pause(300)
|
||||
})
|
||||
```
|
||||
|
||||
### ~avatar avatar surprised
|
||||
|
||||
### Challenge 3
|
||||
|
||||
### @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**.
|
||||
|
||||
```blocks
|
||||
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(Dimension.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 (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!
|
58
docs/lessons/catch-the-egg-game/quiz-answers.md
Normal file
58
docs/lessons/catch-the-egg-game/quiz-answers.md
Normal file
@ -0,0 +1,58 @@
|
||||
# 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/>
|
||||
|
||||
```blocks
|
||||
let basketX = 2
|
||||
let eggX = 2
|
||||
let eggY = 0
|
||||
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/>
|
||||
|
||||
```blocks
|
||||
let basketX = 2
|
||||
let eggX = 2
|
||||
let eggY = 0
|
||||
led.unplot(eggX, eggY)
|
||||
eggY = eggY + 1
|
||||
led.plot(eggX, eggY)
|
||||
```
|
||||
|
||||
## 4. . Write the code that resets the egg after it has fallen past the bottom of the BBC micro:bit.
|
||||
|
||||
<br/>
|
||||
|
||||
```blocks
|
||||
let eggX = 2
|
||||
let eggY = 0
|
||||
if (eggY > 4) {
|
||||
eggY = -1
|
||||
eggX = Math.random(5)
|
||||
}
|
||||
```
|
||||
|
30
docs/lessons/catch-the-egg-game/quiz.md
Normal file
30
docs/lessons/catch-the-egg-game/quiz.md
Normal file
@ -0,0 +1,30 @@
|
||||
# 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 challenges](/microbit/lessons/catch-the-egg-game/activity)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Write the data type for the 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 resets the egg after it has fallen past the bottom of the BBC micro:bit.
|
||||
|
||||
<br/>
|
||||
|
@ -11,9 +11,7 @@ Music
|
||||
* [activity](/microbit/lessons/classic-beatbox/activity)
|
||||
* [challenges](/microbit/lessons/classic-beatbox/challenges)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
@ -23,40 +21,3 @@ Learn how to make a beatbox music player using pins P1 and P2. We will be learni
|
||||
|
||||
* learn how to code music on the BBC micro:bit
|
||||
|
||||
## 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
|
||||
|
||||
#### 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.
|
||||
* [activity](/microbit/lessons/classic-beatbox/activity)
|
||||
|
||||
## Extended Activity
|
||||
|
||||
* time: 20 min.
|
||||
* [challenges](/microbit/lessons/classic-beatbox/challenges)
|
||||
|
||||
## Homework
|
||||
|
||||
* Extended Activity: [challenges](/microbit/lessons/classic-beatbox/challenges)
|
||||
|
||||
|
@ -12,7 +12,8 @@ If (Conditionals)
|
||||
|
||||
* [activity](/microbit/lessons/compass/activity)
|
||||
* [challenges](/microbit/lessons/compass/challenges)
|
||||
|
||||
* [quiz](/microbit/lessons/compass/quiz)
|
||||
* [quiz answers](/microbit/lessons/compass/quiz-answers)
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
|
@ -41,7 +41,7 @@ If `degrees` is less than 135, the micro:bit is mostly pointing East. Display `E
|
||||
|
||||
|
||||
```blocks
|
||||
let degrees = null;
|
||||
let degrees = 0;
|
||||
basic.forever(() => {
|
||||
degrees = input.compassHeading();
|
||||
if (degrees < 45) {
|
||||
@ -57,7 +57,7 @@ If `degrees` is less than 225, the micro:bit is mostly pointing South. Display `
|
||||
|
||||
|
||||
```blocks
|
||||
let degrees = null;
|
||||
let degrees = 0;
|
||||
basic.forever(() => {
|
||||
degrees = input.compassHeading();
|
||||
if (degrees < 45) {
|
||||
@ -76,7 +76,7 @@ basic.forever(() => {
|
||||
If none of these conditions returned true, then the micro:bit must be pointing West. Display `W` on the micro:bit.
|
||||
|
||||
```blocks
|
||||
let degrees = null;
|
||||
let degrees = 0;
|
||||
basic.forever(() => {
|
||||
degrees = input.compassHeading();
|
||||
if (degrees < 45) {
|
||||
|
@ -7,7 +7,7 @@ Display the direction that the micro:bit is facing using the compass
|
||||
Complete the following [guided tutorial](/microbit/lessons/compass/activity), your code should look like this:
|
||||
|
||||
```blocks
|
||||
let degrees = null;
|
||||
let degrees = 0;
|
||||
basic.forever(() => {
|
||||
degrees = input.compassHeading();
|
||||
if (degrees < 45) {
|
||||
@ -30,7 +30,7 @@ basic.forever(() => {
|
||||
Instead of displaying `N` when the BBC micro:bit is pointing North, display a star to indicate the north star.
|
||||
|
||||
```blocks
|
||||
let degrees = null;
|
||||
let degrees = 0;
|
||||
basic.forever(() => {
|
||||
degrees = input.compassHeading();
|
||||
if (degrees < 45) {
|
||||
@ -61,7 +61,7 @@ basic.forever(() => {
|
||||
Instead of displaying just `N`, `W`, `S`, or `E`, display the full word.
|
||||
|
||||
```blocks
|
||||
let degrees = null;
|
||||
let degrees = 0;
|
||||
basic.forever(() => {
|
||||
degrees = input.compassHeading();
|
||||
if (degrees < 45) {
|
||||
|
@ -26,6 +26,7 @@ let degrees = input.compassHeading()
|
||||
|
||||
|
||||
```blocks
|
||||
let degrees = input.compassHeading()
|
||||
if (degrees < 45) {
|
||||
basic.showString("N", 150)
|
||||
}
|
||||
@ -35,6 +36,7 @@ if (degrees < 45) {
|
||||
|
||||
|
||||
```blocks
|
||||
let degrees = input.compassHeading()
|
||||
if (degrees < 135) {
|
||||
basic.showString("E", 150)
|
||||
}
|
||||
@ -44,6 +46,7 @@ if (degrees < 135) {
|
||||
|
||||
|
||||
```blocks
|
||||
let degrees = input.compassHeading()
|
||||
if (degrees < 225) {
|
||||
basic.showString("S", 150)
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ Variables
|
||||
|
||||
* [activity](/microbit/lessons/counter/activity)
|
||||
* [challenges](/microbit/lessons/counter/challenges)
|
||||
* [quiz](/microbit/lessons/counter/quiz)
|
||||
* [quiz answers](/microbit/lessons/counter/quiz-answers)
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
|
@ -27,10 +27,10 @@ let count = 0
|
||||
## 3. Draw which LEDs are ON after running this code and pressing button "A" once. Explain you chose to draw that number
|
||||
|
||||
```blocks
|
||||
let count_ = 0
|
||||
let counts = 0
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
count_ = count_ + 1
|
||||
basic.showNumber(count_, 100)
|
||||
counts = counts + 1
|
||||
basic.showNumber(counts, 150)
|
||||
})
|
||||
```
|
||||
|
||||
@ -41,10 +41,10 @@ input.onButtonPressed(Button.A, () => {
|
||||
## 4. Draw which LEDs are ON after running this code and pressing button "A" three times. Explain you chose to draw that number
|
||||
|
||||
```blocks
|
||||
count_ = 0
|
||||
let counting= 0
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
count_ = count_ + 1
|
||||
basic.showNumber(count_, 100)
|
||||
counting = counting + 1
|
||||
basic.showNumber(counting, 100)
|
||||
})
|
||||
```
|
||||
|
||||
|
@ -12,7 +12,8 @@ If (Conditionals)
|
||||
|
||||
* [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)
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
|
@ -6,7 +6,7 @@ Create a die when the BBC micro:bit is shaken
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [die roll tutorial](/microbit/lessons/die-roll/tutorial).
|
||||
Use this activity document to guide your work in the [die roll tutorial](/microbit/lessons/die-roll/activity).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
|
@ -12,6 +12,8 @@ While Loop
|
||||
|
||||
* [activity](/microbit/lessons/digi-yoyo/activity)
|
||||
* [challenges](/microbit/lessons/digi-yoyo/challenges)
|
||||
* [quiz](/microbit/lessons/digi-yoyo/quiz)
|
||||
* [quiz answers](/microbit/lessons/digi-yoyo/quiz-answers)
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
@ -20,20 +22,12 @@ Learn how to creating a **while loop**, `while condition do` to repeat code whil
|
||||
## Documentation
|
||||
|
||||
```docs
|
||||
|
||||
let x = 0
|
||||
|
||||
basic.showNumber(0)
|
||||
|
||||
|
||||
while (true) {
|
||||
|
||||
basic.pause(20)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
```
|
||||
|
||||
## Objectives
|
||||
|
@ -18,7 +18,6 @@ let count = 0
|
||||
|
||||
Add a while loop that will loop over and over until the variable `count` equals 10.
|
||||
|
||||

|
||||
|
||||
```blocks
|
||||
let count = 0
|
||||
|
@ -69,5 +69,7 @@ Now, we need `count` to decrease by one after the micro:bit has displayed the va
|
||||
We can do this by adding this line:
|
||||
|
||||
```blocks
|
||||
let count = count + (count - 1);
|
||||
let count = 0;
|
||||
count = count + (count - 1);
|
||||
|
||||
```
|
||||
|
@ -16,7 +16,7 @@ A loop that repeats code while a condition is true.
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
```blocks
|
||||
let count = 0
|
||||
```
|
||||
|
||||
@ -26,7 +26,8 @@ let count = 0
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
```blocks
|
||||
let count = 0
|
||||
while (count < 5) {
|
||||
count = count + 1
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ Create a counter with a while loop
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [digi yoyo tutorial](/microbit/lessons/digi-yoyo/tutorial)
|
||||
Use this activity document to guide your work in the [digi yoyo tutorial](/microbit/lessons/digi-yoyo/activity)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
|
@ -10,10 +10,8 @@ Acceleration
|
||||
|
||||
* [activity](/microbit/lessons/glowing-pendulum/activity)
|
||||
* [challenges](/microbit/lessons/glowing-pendulum/challenges)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
* [quiz](/microbit/lessons/glowing-pendulum/quiz)
|
||||
* [quiz answers](/microbit/lessons/glowing-pendulum/quiz-answers)
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
|
@ -29,16 +29,19 @@ let acceleration = input.acceleration("y")
|
||||
<br/>
|
||||
|
||||
```blocks
|
||||
let acceleration = math.abs(acceleration)
|
||||
let acceleration = input.acceleration(Dimension.X)
|
||||
let accelerationAbsolute = Math.abs(acceleration)
|
||||
```
|
||||
|
||||
## 4. Write the code that uses the acceleration value from question #3 to set the brightness on the BBC micro:bit.
|
||||
## 4. Write the code to use the acceleration value from question 3 to set the brightness on the BBC micro:bit.
|
||||
|
||||
<br/>
|
||||
|
||||
```blocks
|
||||
let acceleration = acceleration / 4
|
||||
led.setBrightness(acceleration)
|
||||
let accelerationX = input.acceleration(Dimension.X)
|
||||
let accelerationAbsolute = Math.abs(accelerationX)
|
||||
let accelerationDivided = accelerationX / 4
|
||||
led.setBrightness(accelerationX)
|
||||
```
|
||||
|
||||
## 5. Write the code that tuns all the LEDs on (as the image displays below)
|
||||
|
@ -6,7 +6,7 @@ construct a pendulum that glows using acceleration #LED #number #math #accelerat
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [glowing pendulum tutorial](/microbit/lessons/glowing-pendulum/tutorial)
|
||||
Use this activity document to guide your work in the [glowing pendulum tutorial](/microbit/lessons/glowing-pendulum/activity)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
@ -22,7 +22,7 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
|
||||
|
||||
<br/>
|
||||
|
||||
## 4. Write the code that uses the acceleration value from question #3 to set the brightness on the BBC micro:bit.
|
||||
## 4. Write the code to include acceleration value question 3 to set the brightness on the BBC micro:bit.
|
||||
|
||||
<br/>
|
||||
|
||||
|
@ -12,6 +12,8 @@ Math - Pick Random
|
||||
|
||||
* [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)
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
|
@ -31,7 +31,7 @@ let 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.
|
||||
|
||||
```blocks
|
||||
randomNumber = Math.random(10)
|
||||
let randomNumber = Math.random(10)
|
||||
```
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@ Learn how to generate a random number on the micro:bit. #math #random #docs
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [guess the number tutorial](/microbit/lessons/guess-the-number/tutorial).
|
||||
Use this activity document to guide your work in the [guess the number tutorial](/microbit/lessons/guess-the-number/activity).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
|
@ -10,10 +10,6 @@ Hack your headphone
|
||||
|
||||
* [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).
|
||||
|
@ -12,6 +12,9 @@ For Loop
|
||||
|
||||
* [activity](/microbit/lessons/looper/activity)
|
||||
* [challenges](/microbit/lessons/looper/challenges)
|
||||
* [quiz](/microbit/lessons/looper/quiz)
|
||||
* [quiz answers](/microbit/lessons/looper/quiz-answers)
|
||||
|
||||
|
||||
## Class
|
||||
|
||||
|
@ -6,7 +6,7 @@ Learn how to create a series of numbers with a for loop. #LED #screen #plot #doc
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [looper tutorial](/microbit/lessons/looper/tutorial)
|
||||
Use this activity document to guide your work in the [looper tutorial](/microbit/lessons/looper/activity)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
|
@ -10,6 +10,8 @@ If (Conditionals)
|
||||
|
||||
* [activity](/microbit/lessons/magic-8/activity)
|
||||
* [challenges](/microbit/lessons/magic-8/challenges)
|
||||
* [quiz](/microbit/lessons/magic-8/quiz)
|
||||
* [quiz answers](/microbit/lessons/magic-8/quiz-answers)
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
@ -28,7 +30,6 @@ input.onGesture(Gesture.Shake, () => {
|
||||
basic.showNumber(7)
|
||||
basic.clearScreen()
|
||||
basic.showString("Hello!")
|
||||
|
||||
```
|
||||
|
||||
## Objectives
|
||||
|
@ -25,12 +25,13 @@ let x = Math.random(3)
|
||||
## 3. Write the 'if statement' to check if ``x`` is equal to 2. Inside the 'if statement', display the string "Yes".
|
||||
|
||||
```blocks
|
||||
let x = Math.random(3)
|
||||
if (x == 2) {
|
||||
basic.showString("Yes", 150)
|
||||
}
|
||||
```
|
||||
|
||||
## 3. Write the 'if statement' to check if ``x`` is equal to 1. Inside the 'if statement', display the string "No."
|
||||
## 4. Write the 'if statement' to check if ``x`` is equal to 1. Inside the 'if statement', display the string "No."
|
||||
|
||||
```blocks
|
||||
let x = Math.random(3)
|
||||
|
@ -6,7 +6,7 @@ create a magic 8 ball on the BBC micro:bit #math #random #docs
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [magic 8 tutorial](/microbit/lessons/magic-8/tutorial).
|
||||
Use this activity document to guide your work in the [magic 8 tutorial](/microbit/lessons/magic-8/activity).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
@ -22,7 +22,7 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
|
||||
|
||||
<br />
|
||||
|
||||
## 3. Write the 'if statement' to check if ``x`` is equal to 1. Inside the 'if statement', display the string "No."
|
||||
## 4. Write the 'if statement' to check if ``x`` is equal to 1. Inside the 'if statement', display the string "No."
|
||||
|
||||
<br />
|
||||
|
||||
|
@ -12,6 +12,8 @@ On Logo Up
|
||||
|
||||
* [activity](/microbit/lessons/magic-logo/activity)
|
||||
* [challenges](/microbit/lessons/magic-logo/challenges)
|
||||
* [quiz](/microbit/lessons/magic-logo/challenges)
|
||||
* [quiz answers](/microbit/lessons/magic-logo/challenges)
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
|
@ -22,7 +22,7 @@ When the micro:bit goes logo up, the code nested under the `on logo up` function
|
||||
|
||||
```blocks
|
||||
input.onLogoUp(() => {
|
||||
basic.showAnimation(`
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
@ -31,6 +31,7 @@ input.onLogoUp(() => {
|
||||
`)
|
||||
})
|
||||
|
||||
|
||||
```
|
||||
|
||||
Run your code and try to turn around the micro:bit to see the **logo up** event in action!
|
||||
|
@ -8,7 +8,7 @@ Complete the [magic logo](/microbit/lessons/magic-logo/activity) activity and yo
|
||||
|
||||
```blocks
|
||||
input.onLogoUp(() => {
|
||||
basic.showAnimation(`
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
@ -28,7 +28,7 @@ How about when the logo is down? We should display an arrow pointing downward!
|
||||
|
||||
```blocks
|
||||
input.onLogoUp(() => {
|
||||
basic.showAnimation(`
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
@ -37,7 +37,7 @@ input.onLogoUp(() => {
|
||||
`)
|
||||
})
|
||||
input.onLogoDown(() => {
|
||||
basic.showAnimation(`
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
# # # # #
|
||||
|
@ -44,7 +44,7 @@ input.onLogoUp(() => {
|
||||
|
||||
```blocks
|
||||
input.onLogoDown(() => {
|
||||
basic.plotImage(`
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
# # # # #
|
||||
|
@ -12,6 +12,8 @@ Set Brightness
|
||||
|
||||
* [activity](/microbit/lessons/night-light/activity)
|
||||
* [challenges](/microbit/lessons/night-light/challenges)
|
||||
* [quiz](/microbit/lessons/night-light/quiz)
|
||||
* [quiz answers](/microbit/lessons/night-light/quiz-answers)
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
|
@ -16,9 +16,15 @@ If the rectangle above represents the BBC micro:bit, write the code to set all t
|
||||
|
||||
<br />
|
||||
|
||||
```
|
||||
```blocks
|
||||
led.setBrightness(255)
|
||||
led.plotAll()
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
`)
|
||||
```
|
||||
|
||||
## 3. Consider the following image
|
||||
@ -29,9 +35,15 @@ If the rectangle above represents the BBC micro:bit, write the code to set the s
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
```blocks
|
||||
led.setBrightness(128)
|
||||
led.plotAll()
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
`)
|
||||
```
|
||||
|
||||
## 4. Consider the following image
|
||||
@ -40,7 +52,7 @@ led.plotAll()
|
||||
|
||||
If the rectangle above represents the BBC micro:bit, write the code to turn off all the LEDs.
|
||||
|
||||
```
|
||||
```blocks
|
||||
led.setBrightness(0)
|
||||
```
|
||||
|
||||
|
@ -6,7 +6,7 @@ change the brightness of the BBC micro:bit #LED #image #brightness #fade #docs
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [night light tutorial](/microbit/lessons/night-light/tutorial)
|
||||
Use this activity document to guide your work in the [night light tutorial](/microbit/lessons/night-light/activity)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
|
21
docs/lessons/ornament-chain.md
Normal file
21
docs/lessons/ornament-chain.md
Normal file
@ -0,0 +1,21 @@
|
||||
# ornament chain lesson
|
||||
|
||||
display beautiful images on the BBC micro:bit #var #pause #docs
|
||||
|
||||
## Topic
|
||||
|
||||
Network devices
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [activity](/microbit/lessons/ornament-chain/activity)
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to convert your BBC micro:bit into a telegraph using a second BBC micro:bit as well as pin P1, P2, 3V, GND, and crocodile clips (or spring clips). The connect BBC micro:bit uses pins P1, P2, 3V, GND.
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to setup the BBC micro:bit with crocodile clips
|
||||
* learn how to telegraph to another BBC micro:bit
|
||||
|
@ -6,7 +6,7 @@ shift an image horizontally across the display with offset #offset #screen #var
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [rock paper scissors tutorial](/microbit/lessons/rock-paper-scissors/tutorial).
|
||||
Use this activity document to guide your work in the [rock paper scissors tutorial](/microbit/lessons/rock-paper-scissors/activity).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
|
@ -10,10 +10,8 @@ While Loop
|
||||
|
||||
* [activity](/microbit/lessons/rotation-animation/activity)
|
||||
* [challenges](/microbit/lessons/rotation-animation/challenges)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
* [quiz](/microbit/lessons/rotation-animation/quiz)
|
||||
* [quiz answers](/microbit/lessons/rotation-animation/quiz-answers)
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
@ -38,17 +36,14 @@ while (true) {
|
||||
|
||||
basic.pause(20)
|
||||
}
|
||||
|
||||
|
||||
|
||||
```
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to create a global variable for a place where you can store data, accessible across functions, and in nested code blocks
|
||||
* learn how to set or change the value of a global variable
|
||||
* learn how to create a variable for a place where you can store data, accessible across functions, and in nested code blocks
|
||||
* learn how to set or change the value of a variable
|
||||
* learn how to repeat code while a condition is true
|
||||
* learn how to declare a global boolean variable to determine which code will execute next
|
||||
* learn how to declare a boolean variable to determine which code will execute next
|
||||
* learn how to run code when an input button is pressed
|
||||
* learn how to show a series of image frames on the LED screen
|
||||
* learn how to pause your code for the specified number of milliseconds
|
||||
|
@ -54,9 +54,6 @@ Now let's add to this by creating a condition for on button pressed `A` before t
|
||||
```blocks
|
||||
|
||||
let rotating = true;
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
serial.writeLine("hello")
|
||||
})
|
||||
while (rotating) {
|
||||
serial.writeLine("loop")
|
||||
basic.showLeds(`
|
||||
@ -88,8 +85,9 @@ while (rotating) {
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
|
||||
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
serial.writeLine("hello")
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
@ -101,10 +99,6 @@ Now that we have the on button pressed condition, let's make the animation stop
|
||||
|
||||
```blocks
|
||||
let rotating = true;
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
serial.writeLine("hello")
|
||||
rotating = false
|
||||
})
|
||||
while (rotating) {
|
||||
serial.writeLine("loop")
|
||||
basic.showLeds(`
|
||||
@ -136,7 +130,10 @@ while (rotating) {
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
serial.writeLine("hello")
|
||||
rotating = false
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
|
@ -4,44 +4,82 @@ Learn how to create a rotating image with a while loop. #image #loop #while #do
|
||||
|
||||
This is the answer key for the [rotation animation quiz](/microbit/lessons/rotation-animation/quiz).
|
||||
|
||||
## 1. What is a "global variable"?
|
||||
## 1. What is a " variable"?
|
||||
|
||||
Answers may vary. A global variable is a place where you can store data so that you can use it later in your code.
|
||||
Answers may vary. A variable is a place where you can store data so that you can use it later in your code.
|
||||
|
||||
## 2. Consider the following directions
|
||||
## 2. Write the code to create a ** variable** called `foo` that stores a boolean and initialize it to **false**.
|
||||
|
||||
Write the code to create a **global variable** called `foo` that stores a boolean and initialize it to **false**.
|
||||
|
||||
```
|
||||
rotating = true
|
||||
|
||||
```blocks
|
||||
let rotating = true;
|
||||
```
|
||||
|
||||
## 3. Consider the following code
|
||||
## 3. Explain what this line of code does.
|
||||
|
||||
```
|
||||
```blocks
|
||||
let rotating = true;
|
||||
while (rotating) {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Explain what this line of code does.
|
||||
|
||||
|
||||
<br/>
|
||||
|
||||
It is a **while** loop that will be executed only if the **global variable** called `rotating` is **true**.
|
||||
It is a **while** loop that will be executed only if the ** variable** called `rotating` is **true**.
|
||||
|
||||
## 4. Consider the following code
|
||||
## 4. If the rectangle below represents the BBC micro:bit, shade the areas that will be displayed. Explain why that particular area is shaded.
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
# . . . . . . # . . . . . . # . . . . .
|
||||
. # . . . . . # . . . . . # . . . . . .
|
||||
. . # . . . . # . . . . # . . # # # # #
|
||||
. . . # . . . # . . . # . . . . . . . .
|
||||
. . . . # . . # . . # . . . . . . . . .
|
||||
`, 400)
|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
# # # # #
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . #
|
||||
. . . # .
|
||||
. . # . .
|
||||
. # . . .
|
||||
# . . . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . #
|
||||
. . . # .
|
||||
. . # . .
|
||||
. # . . .
|
||||
# . . . .
|
||||
`)
|
||||
|
||||
```
|
||||
|
||||
If the rectangle below represents the BBC micro:bit, shade the areas that will be displayed. Explain why that particular area is shaded.
|
||||
|
||||
|
||||

|
||||
|
||||
|
@ -6,37 +6,75 @@ Learn how to create a rotating image with a while loop. #image #loop #while #do
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [rotation animation tutorial](/microbit/lessons/rotation-animation/tutorial).
|
||||
Use this activity document to guide your work in the [rotation animation tutorial](/microbit/lessons/rotation-animation/activity).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. What is a "global variable"?
|
||||
## 1. What is a " variable"?
|
||||
|
||||
<br />
|
||||
|
||||
## 2. Write the code to create a global variable called foo that stores a boolean and initialize it to false.
|
||||
## 2. Write the code to create a variable called foo that stores a boolean and initialize it to false.
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. Explain why you use a while loop with a global variable
|
||||
## 3. Explain why you use a while loop with a variable
|
||||
|
||||
```
|
||||
```blocks
|
||||
let rotating = true;
|
||||
while (rotating) {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
||||
## 4. Draw the areas on the micro:bits to illustrate the code below. Explain why you chose to draw in those areas.
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
# . . . . . . # . . . . . . # . . . . .
|
||||
. # . . . . . # . . . . . # . . . . . .
|
||||
. . # . . . . # . . . . # . . # # # # #
|
||||
. . . # . . . # . . . # . . . . . . . .
|
||||
. . . . # . . # . . # . . . . . . . . .
|
||||
`, 400)
|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
# # # # #
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . #
|
||||
. . . # .
|
||||
. . # . .
|
||||
. # . . .
|
||||
# . . . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . #
|
||||
. . . # .
|
||||
. . # . .
|
||||
. # . . .
|
||||
# . . . .
|
||||
`)
|
||||
|
||||
```
|
||||
|
||||

|
||||
|
@ -13,14 +13,14 @@ Welcome! This tutorial will help you make a smiley face blink. Let's get started
|
||||
Create an animation with an image displaying a smiley face and the next image with no LEDs lit up. This will make it look like the smiley face is blinking as the display switches between images.
|
||||
|
||||
```blocks
|
||||
basic.showAnimation(`
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
basic.showAnimation(`
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
|
@ -8,14 +8,14 @@ Complete the [smiley activity](/microbit/lessons/smiley/activity) and your code
|
||||
|
||||
|
||||
```blocks
|
||||
basic.showAnimation(`
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
basic.showAnimation(`
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
@ -33,14 +33,14 @@ Let's make add code that will run when button A is pressed!
|
||||
|
||||
|
||||
```blocks
|
||||
basic.showAnimation(`
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
basic.showAnimation(`
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
@ -59,14 +59,14 @@ input.onButtonPressed(Button.A, () => {
|
||||
Now, we want to show a frowny face when this button is pressed. Let's show the LEDs.
|
||||
|
||||
```blocks
|
||||
basic.showAnimation(`
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
basic.showAnimation(`
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
@ -74,7 +74,7 @@ basic.showAnimation(`
|
||||
. . . . .
|
||||
`)
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showAnimation(`
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. # . # .
|
||||
. . . . .
|
||||
|
@ -51,7 +51,7 @@ basic.forever(() => {
|
||||
. . # . .
|
||||
`)
|
||||
})
|
||||
```blocks
|
||||
```
|
||||
|
||||
Run your code in the simulator or download it to your BBC micro:bit to see what happens!
|
||||
|
||||
|
@ -6,25 +6,59 @@ Coding challenges for snowflake fall.
|
||||
|
||||
Complete the [snowflake fall](/microbit/lessons/snowflake-fall/activity) activity and your code will look like this:
|
||||
|
||||

|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . # . .
|
||||
. # # # .
|
||||
. . # . .
|
||||
. . . . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # . # .
|
||||
# . . . #
|
||||
. # . # .
|
||||
. . # . .
|
||||
`)
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
### @video td/videos/snowflake-fall-1
|
||||
|
||||
Let's begin creating our falling effect by adding another snowflake with `show LEDs` that displays a different snowflake pattern after the first one. We need 2 frames in the new animation that display both the first and the second snowflake images.
|
||||
|
||||

|
||||
|
||||
* Run your program to see the cool animation.
|
||||
|
||||
### Challenge 2
|
||||
|
||||
### @video td/videos/snowflake-fall-2
|
||||
|
||||
To finalize our snowflake fall, let's add a different snowflake pattern.
|
||||
|
||||

|
||||
```blocks
|
||||
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . # . .
|
||||
. # # # .
|
||||
. . # . .
|
||||
. . . . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # . # .
|
||||
# . . . #
|
||||
. # . # .
|
||||
. . # . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# # # # #
|
||||
. # . # .
|
||||
# # # # #
|
||||
. # . # .
|
||||
`)
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
|
||||
* Run your program and see if it works.
|
||||
|
||||
|
@ -28,7 +28,24 @@ basic.forever(() => {
|
||||
|
||||

|
||||
|
||||

|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . # . .
|
||||
. # # # .
|
||||
. . # . .
|
||||
. . . . .
|
||||
`);
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
});
|
||||
```
|
||||
|
||||
## 4. Write the code for a forever loop and show LEDS for these images!
|
||||
|
||||
@ -36,5 +53,21 @@ basic.forever(() => {
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . # . .
|
||||
. # # # .
|
||||
. . # . .
|
||||
. . . . .
|
||||
`);
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# # . # #
|
||||
# . # . #
|
||||
# # . # #
|
||||
# # # # #
|
||||
`)
|
||||
});
|
||||
```
|
@ -12,6 +12,8 @@ If (Conditionals)
|
||||
|
||||
* [activity](/microbit/lessons/spinner/activity)
|
||||
* [challenges](/microbit/lessons/spinner/challenges)
|
||||
* [quiz](/microbit/lessons/spinner/quiz)
|
||||
* [quiz answers](/microbit/lessons/spinner/quiz-answers)
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
|
@ -12,19 +12,95 @@ Welcome! This guided tutorial will teach how to program a script that randomly p
|
||||
|
||||
Let's begin by adding an `on shake` condition to know when the micro:bit is shaken.
|
||||
|
||||

|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
|
||||
})
|
||||
```
|
||||
|
||||
Now let's randomly generate a number from 0 to 3 so that we can randomly display an arrow in a given direction.
|
||||
|
||||

|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let randomArrow = Math.random(4)
|
||||
if (randomArrow = 3) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
|
||||
Now let's handle each of the cases by displaying the appropriate arrow. (Let's display an up arrow if `random arrow` is 0.
|
||||
|
||||

|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let randomArrow = Math.random(4)
|
||||
if (randomArrow = 3) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
if (randomArrow = 2) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
Now let's handle the rest of the cases for `random arrow`.
|
||||
|
||||

|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let randomArrow = Math.random(4)
|
||||
if (randomArrow = 3) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
if (randomArrow = 2) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
if (randomArrow = 1) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # . .
|
||||
# # # # #
|
||||
. # # . .
|
||||
. . # . .
|
||||
`)
|
||||
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
|
@ -6,21 +6,164 @@ Create an arrow that randomly points to a player.
|
||||
|
||||
Complete the following [guided tutorial](/microbit/lessons/spinner/activity), your code should look like this:
|
||||
|
||||

|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let randomArrow = Math.random(4)
|
||||
if (randomArrow = 3) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
if (randomArrow = 2) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
if (randomArrow = 1) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # . .
|
||||
# # # # #
|
||||
. # # . .
|
||||
. . # . .
|
||||
`)
|
||||
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Modify the random number generator so that it can include new arrows we will create in the next challenge.
|
||||
|
||||

|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let randomArrow = Math.random(8)
|
||||
if (randomArrow = 3) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
if (randomArrow = 2) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
if (randomArrow = 1) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # . .
|
||||
# # # # #
|
||||
. # # . .
|
||||
. . # . .
|
||||
`)
|
||||
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
|
||||
* Do **not** run the code yet because it will not work until you have conditions for every random number.
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Let's add four more arrows that point diagonally.
|
||||
Let's add more arrows that point diagonally.
|
||||
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let randomArrow = Math.random(8)
|
||||
if (randomArrow = 7) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
if (randomArrow = 6) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. . # . .
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .
|
||||
`)
|
||||
}
|
||||
if (randomArrow = 5) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # . .
|
||||
# # # # #
|
||||
. # # . .
|
||||
. . # . .
|
||||
`)
|
||||
|
||||
}
|
||||
if (randomArrow = 4) {
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. . . # .
|
||||
# # # # #
|
||||
. . . # .
|
||||
. . # . .
|
||||
`)
|
||||
|
||||
}
|
||||
|
||||
if (randomArrow = 3) {
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # .
|
||||
# # # # .
|
||||
# . . # .
|
||||
. . . . #
|
||||
`)
|
||||
|
||||
}
|
||||
if (randomArrow = 2) {
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
. . # # #
|
||||
. # . # #
|
||||
# . . . #
|
||||
`)
|
||||
|
||||
}
|
||||
if (randomArrow = 1) {
|
||||
basic.showLeds(`
|
||||
# . . . #
|
||||
# # . # .
|
||||
# # # . .
|
||||
# # # # .
|
||||
# # # # #
|
||||
`)
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
```
|
||||
|
||||

|
||||
|
||||
* Run your code to see if it works as expected
|
||||
|
||||
|
@ -6,7 +6,7 @@ a spin the BBC micro:bit game with the input on shake #math #random #docs #shake
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [spinner tutorial](/microbit/lessons/spinner/tutorial).
|
||||
Use this activity document to guide your work in the [spinner tutorial](/microbit/lessons/spinner/activity).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
|
@ -12,6 +12,8 @@ For Loop
|
||||
|
||||
* [activity](/microbit/lessons/strobe-light/activity)
|
||||
* [challenges](/microbit/lessons/strobe-light/challenges)
|
||||
* [quiz](/microbit/lessons/strobe-light/quiz)
|
||||
* [quiz answers](/microbit/lessons/strobe-light/quiz-answers)
|
||||
|
||||
## Documentation
|
||||
|
||||
|
@ -45,7 +45,14 @@ for (let i = 0; i < 5; i++) {
|
||||
|
||||
The pause will add a delay between lighting each LED.
|
||||
|
||||

|
||||
```blocks
|
||||
for (let i = 0; i < 5; i++) {
|
||||
for (let j = 0; j < 5; j++) {
|
||||
led.plot(i, j)
|
||||
basic.pause(200)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
|
@ -6,7 +6,7 @@ Learn how to create a blinking LED script with a for loop. #LED #screen #plot #d
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [strobe light tutorial](/microbit/lessons/strobe-light/tutorial)
|
||||
Use this activity document to guide your work in the [strobe light tutorial](/microbit/lessons/strobe-light/activity)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
|
@ -10,10 +10,6 @@ Telegraph
|
||||
|
||||
* [activity](/microbit/lessons/telegraph/activity)
|
||||
|
||||
## Class
|
||||
|
||||
Year 7
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to convert your BBC micro:bit into a telegraph using a second BBC micro:bit as well as pin P1, P2, 3V, GND, and crocodile clips (or spring clips). The connect BBC micro:bit uses pins P1, P2, 3V, GND.
|
||||
|
@ -12,6 +12,8 @@ If (Conditionals)
|
||||
|
||||
* [activity](/microbit/lessons/truth-or-dare/activity)
|
||||
* [challenges](/microbit/lessons/truth-or-dare/challenges)
|
||||
* [quiz](/microbit/lessons/truth-or-dare/quiz)
|
||||
* [quiz answers](/microbit/lessons/truth-or-dare/quiz-answers)
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
|
@ -6,7 +6,7 @@ a multi-player game that forces each player to reveal a secret or something funn
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [truth or dare tutorial](/microbit/lessons/truth-or-dare/tutorial).
|
||||
Use this activity document to guide your work in the [truth or dare tutorial](/microbit/lessons/truth-or-dare/activity).
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
|
@ -12,6 +12,8 @@ Acceleration
|
||||
|
||||
* [activity](/microbit/lessons/zoomer/activity)
|
||||
* [challenges](/microbit/lessons/zoomer/challenges)
|
||||
* [quiz](/microbit/lessons/zoomer/quiz)
|
||||
* [quiz answers](/microbit/lessons/zoomer/quiz-answers)
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
@ -21,12 +23,10 @@ Learn how to get the **acceleration**, `acceleration` in one of three specified
|
||||
|
||||
```docs
|
||||
basic.forever(() => {
|
||||
|
||||
})
|
||||
let x = 0
|
||||
input.acceleration(Dimension.X)
|
||||
if (true) {
|
||||
|
||||
}
|
||||
input.buttonIsPressed(Button.A)
|
||||
basic.showNumber(0)
|
||||
|
@ -14,7 +14,7 @@ Write the line of code to measure the acceleration and then store in it a variab
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
```blocks
|
||||
let accX_ = input.acceleration("x")
|
||||
```
|
||||
|
||||
@ -26,9 +26,9 @@ After storing the acceleration in a variable, write the code to show acceleratio
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
```blocks
|
||||
let accX = input.acceleration("x")
|
||||
basic.showNumber(accX_, 150)
|
||||
basic.showNumber(accX, 150)
|
||||
```
|
||||
|
||||
Note: make sure the same variable name ("acc x" in this case) is the same in both lines of code..
|
||||
|
@ -6,7 +6,7 @@ Measure the acceleration on the micro:bit in the "z" direction #LED #number #mat
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [zoomer tutorial](/microbit/lessons/zoomer/tutorial)
|
||||
Use this activity document to guide your work in the [zoomer tutorial](/microbit/lessons/zoomer/activity)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
|
Reference in New Issue
Block a user