updated lesson satic page and pogo

This commit is contained in:
Michael Elliot Braun 2016-03-31 15:51:42 -07:00
parent 7c862ce0f5
commit 1439942b45
7 changed files with 185 additions and 71 deletions

View File

@ -1,7 +1,5 @@
# Lessons # Lessons
Overview of lessons for the BBC micro:bit.
### @short Lessons ### @short Lessons
### ~column ### ~column
@ -52,13 +50,14 @@ Overview of lessons for the BBC micro:bit.
### ~column ### ~column
## Maker ## Maker
* [The Watch](/microbit/lessons/the-watch), design and create The Watch * [The Watch](/microbit/lessons/the-watch), design and create The Watch
* [Hack your Headphones](/microbit/lessons/hack-your-headphones), create music on the BBC micro:bit by hacking your headphones * [Hack your Headphones](/microbit/lessons/hack-your-headphones), create music on the BBC micro:bit by hacking your headphones
* [Banana Keyboard](/microbit/lessons/banana-keyboard), create music with fruits * [Banana Keyboard](/microbit/lessons/banana-keyboard), create music with fruits
* [Telegraph](/microbit/lessons/telegraph), play the telegraph game between two BBC micro:bits * [Telegraph](/microbit/lessons/telegraph), play the telegraph game between two BBC micro:bits
* [Pogo](/microbit/lessons/pogo), create a pogo game to test your jumping abilities
## Advanced ## Advanced
* [Charting](/microbit/lessons/charting), create a charting app between 2 BBC micro:bits
* [Prank WiFi](/microbit/lessons/prank-wifi), create fake WiFi to trick your friends * [Prank WiFi](/microbit/lessons/prank-wifi), create fake WiFi to trick your friends
* [Speed Button](/microbit/lessons/speed-button), code a speed game with running time * [Speed Button](/microbit/lessons/speed-button), code a speed game with running time
* [Headbands](/microbit/lessons/headbands), create a charades game with a collection of strings that hold the words * [Headbands](/microbit/lessons/headbands), create a charades game with a collection of strings that hold the words

View File

@ -10,9 +10,6 @@ Acceleration
* [activity](/microbit/lessons/charting/activity) * [activity](/microbit/lessons/charting/activity)
## Class
Year 7
## Prior learning/place of lesson in scheme of work ## Prior learning/place of lesson in scheme of work

View File

@ -47,7 +47,7 @@ let count = 0
while (count < 10) { while (count < 10) {
basic.pause(100) basic.pause(100)
basic.showNumber(count) basic.showNumber(count)
count == count + 1 count = count + (count - 1)
} }
``` ```

View File

@ -10,24 +10,34 @@ Running Time
* [activity](/microbit/lessons/pogo/activity) * [activity](/microbit/lessons/pogo/activity)
## Class
Year 7
## Prior learning/place of lesson in scheme of work ## Prior learning/place of lesson in scheme of work
Learn how to use running time. We will be learning how to create a pogo game using variables, forever loop, conditionals, on button pressed, as well as simple commands, such as show LEDs and clear screen. Learn how to use running time. We will be learning how to create a pogo game using variables, forever loop, conditionals, on button pressed, as well as simple commands, such as show LEDs and clear screen.
## Documentation ## Documentation
```docs
let jumps = 0
let acc = input.acceleration(Dimension.Y)
basic.showNumber(jumps)
basic.showNumber(radio.receiveNumber())
led.stopAnimation()
jumps = jumps + 1;
radio.sendNumber(jumps)
basic.forever(() => { })
basic.showLeds(`
. . . . .
. # . # .
. . # . .
# . . . #
. # # # .
`)
basic.clearScreen()
if (acc > 2000) {
* **variable** : [read more...](/microbit/reference/variables/var) }
* **arithmetic operator** : [read more...](/microbit/reference/types/number) radio.onDataReceived(() => { })
* **forever** : [read more...](/microbit/reference/basic/forever)
* **on button pressed** : [read more...](/microbit/reference/input/on-button-pressed)
* **if** : [read more...](/microbit/reference/logic/if)
* **clear screen** : [read more...](/microbit/reference/basic/clear-screen)
* **show LEDs** : [read more...](/microbit/reference/basic/show-leds)
```
## Objectives ## Objectives
* learn how to create a function as a unit of code that performs a specific task and returns a result * learn how to create a function as a unit of code that performs a specific task and returns a result
@ -36,25 +46,3 @@ Learn how to use running time. We will be learning how to create a pogo game usi
* learn how to conditionally run code depending on whether a condition is true or not * learn how to conditionally run code depending on whether a condition is true or not
* learn how to run code when an input button is pressed * learn how to run code when an input button is pressed
* learn how to pause your code for the specified number of milliseconds * 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)
* 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
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation

View File

@ -8,29 +8,159 @@ Welcome! This activity will teach how to construct a pendulum that glows using a
Create a **forever** loop that will constantly display the appropriate brightness on the LED display. Now let's measure the acceleration on the `y` axis and store that value in a variable. The `acceleration(y)` function will provide the value. Create a **forever** loop that will constantly display the appropriate brightness on the LED display. Now let's measure the acceleration on the `y` axis and store that value in a variable. The `acceleration(y)` function will provide the value.
![](/static/mb/blocks/lessons/pogo-0.jpg) ```blocks
basic.forever(() => {
let acc = input.acceleration(Dimension.Y)
})
```
Since the micro:bit will be swinging up and down, we need to store the variable called jumps. We will set the variable called jumps to 0 to store the number 0. Since the micro:bit will be swinging up and down, we need to store the variable called jumps. We will set the variable called jumps to 0 to store the number 0.
![](/static/mb/blocks/lessons/pogo-1.jpg) ```blocks
let jumps = 0
basic.forever(() => {
let acc = input.acceleration(Dimension.Y)
})
```
The function `acceleration(y)` gets the acceleration value (milli g-force), in the `y` dimension. If the `acceleration(y)`is greater than 2000 milli g-force, we will change jumps by 1. The function `acceleration(y)` gets the acceleration value (milli g-force), in the `y` dimension. If the `acceleration(y)`is greater than 2000 milli g-force, we will change jumps by 1. If jumping is greater than 2000 milli-gravities, then change jumps by 1 and display a smiley on the BBC micro:bit. Finally, we will remove the smiley image from the screen
If the `acceleration(y)`is greater than 2000 milli g-force, we will display the image with `show LEDs` to display a smiley face on the LEDs and `clear screen` to to turn off all the LED lights on the LED screen.
![](/static/mb/blocks/lessons/pogo-2.jpg) ```blocks
let jumps = 0
basic.forever(() => {
let acc = input.acceleration(Dimension.Y)
if (acc > 2000) {
jumps = jumps + 1;
basic.showLeds(`
. . . . .
. # . # .
. . # . .
# . . . #
. # # # .
`)
basic.clearScreen()
}
})
```
Now let's register an event handler that will execute whenever an input button (A) is pressed during program execution. Now let's register an event handler that will execute whenever an input button (A) is pressed during program execution. If you press button A, then show the number of jumps greater than 2000 milli-gravities on the BBC micro:bit.
![](/static/mb/blocks/lessons/pogo-3.jpg) ```blocks
let jumps = 0
basic.forever(() => {
let acc = input.acceleration(Dimension.Y)
if (acc > 2000) {
jumps = jumps + 1;
basic.showLeds(`
. . . . .
. # . # .
. . # . .
# . . . #
. # # # .
`)
basic.clearScreen()
}
})
input.onButtonPressed(Button.A, () => {
basic.showNumber(jumps)
})
```
Let's show what the brightness of the micro:bit is by turning all the LEDs on! If you press button A+B together, then reset the jump counter to 0 on the BBC micro:bit. Finally, we will show the show the jump counter on the micro:bit
![](/static/mb/blocks/lessons/glowing-pendulum-5.png)
### ~avatar avatar ```blocks
let jumps = 0
basic.forever(() => {
let acc = input.acceleration(Dimension.Y)
if (acc > 2000) {
jumps = jumps + 1;
basic.showLeds(`
. . . . .
. # . # .
. . # . .
# . . . #
. # # # .
`)
basic.clearScreen()
}
})
input.onButtonPressed(Button.A, () => {
basic.showNumber(jumps)
})
input.onButtonPressed(Button.AB, () => {
let jumps = 0
basic.showNumber(jumps)
})
Excellent, you're ready to continue with the [challenges](/microbit/lessons/glowing-pendulum/challenges)! ```
### ~ We want to setup the radio communication between an additional micro:bit. We first must send number for jumps. The additional micro:bit will receive the number and show number on data received. We are now displaying the current jump count on the second micro:bit
```blocks
let jumps = 0
basic.forever(() => {
let acc = input.acceleration(Dimension.Y)
if (acc > 2000) {
jumps = jumps + 1;
radio.sendNumber(jumps)
basic.showLeds(`
. . . . .
. # . # .
. . # . .
# . . . #
. # # # .
`)
basic.clearScreen()
}
})
input.onButtonPressed(Button.A, () => {
basic.showNumber(jumps)
})
input.onButtonPressed(Button.AB, () => {
let jumps = 0
basic.showNumber(jumps)
})
radio.onDataReceived(() => {
basic.showNumber(radio.receiveNumber())
})
```
We want to stop animation so every time the number of jumps increase by 1 the second micro:bit will not also display smiley from show leds. So we add the code stop animation
```blocks
let jumps = 0
basic.forever(() => {
let acc = input.acceleration(Dimension.Y)
if (acc > 2000) {
jumps = jumps + 1;
radio.sendNumber(jumps)
basic.showLeds(`
. . . . .
. # . # .
. . # . .
# . . . #
. # # # .
`)
basic.clearScreen()
}
})
input.onButtonPressed(Button.A, () => {
basic.showNumber(jumps)
})
input.onButtonPressed(Button.AB, () => {
let jumps = 0
basic.showNumber(jumps)
})
radio.onDataReceived(() => {
basic.showNumber(radio.receiveNumber())
led.stopAnimation()
})
```
Connect the first micro:bit to your computer using your USB cable and run the pogo script on it.
Connect the second micro:bit to your computer using your USB cable and run the pogo script on it.
The first person and second person take turns jumping in the “y” direction while the other player uses the micro:bit to track the results on the micro:bit!

View File

@ -23,7 +23,7 @@ Now let's randomly generate a number from 0 to 3 so that we can randomly display
```blocks ```blocks
input.onGesture(Gesture.Shake, () => { input.onGesture(Gesture.Shake, () => {
let randomArrow = Math.random(4) let randomArrow = Math.random(4)
if (randomArrow = 3) { if (randomArrow == 3) {
basic.showLeds(` basic.showLeds(`
. . # . . . . # . .
. # # # . . # # # .
@ -42,7 +42,7 @@ Now let's handle each of the cases by displaying the appropriate arrow. (Let's d
```blocks ```blocks
input.onGesture(Gesture.Shake, () => { input.onGesture(Gesture.Shake, () => {
let randomArrow = Math.random(4) let randomArrow = Math.random(4)
if (randomArrow = 3) { if (randomArrow == 3) {
basic.showLeds(` basic.showLeds(`
. . # . . . . # . .
. # # # . . # # # .
@ -51,7 +51,7 @@ input.onGesture(Gesture.Shake, () => {
. . # . . . . # . .
`) `)
} }
if (randomArrow = 2) { if (randomArrow == 2) {
basic.showLeds(` basic.showLeds(`
. . # . . . . # . .
. . # . . . . # . .
@ -70,7 +70,7 @@ Now let's handle the rest of the cases for `random arrow`.
```blocks ```blocks
input.onGesture(Gesture.Shake, () => { input.onGesture(Gesture.Shake, () => {
let randomArrow = Math.random(4) let randomArrow = Math.random(4)
if (randomArrow = 3) { if (randomArrow == 3) {
basic.showLeds(` basic.showLeds(`
. . # . . . . # . .
. # # # . . # # # .
@ -79,7 +79,7 @@ input.onGesture(Gesture.Shake, () => {
. . # . . . . # . .
`) `)
} }
if (randomArrow = 2) { if (randomArrow == 2) {
basic.showLeds(` basic.showLeds(`
. . # . . . . # . .
. . # . . . . # . .
@ -88,7 +88,7 @@ input.onGesture(Gesture.Shake, () => {
. . # . . . . # . .
`) `)
} }
if (randomArrow = 1) { if (randomArrow == 1) {
basic.showLeds(` basic.showLeds(`
. . # . . . . # . .
. # # . . . # # . .

View File

@ -9,7 +9,7 @@ Complete the following [guided tutorial](/microbit/lessons/spinner/activity), yo
```blocks ```blocks
input.onGesture(Gesture.Shake, () => { input.onGesture(Gesture.Shake, () => {
let randomArrow = Math.random(4) let randomArrow = Math.random(4)
if (randomArrow = 3) { if (randomArrow == 3) {
basic.showLeds(` basic.showLeds(`
. . # . . . . # . .
. # # # . . # # # .
@ -18,7 +18,7 @@ input.onGesture(Gesture.Shake, () => {
. . # . . . . # . .
`) `)
} }
if (randomArrow = 2) { if (randomArrow == 2) {
basic.showLeds(` basic.showLeds(`
. . # . . . . # . .
. . # . . . . # . .
@ -27,7 +27,7 @@ input.onGesture(Gesture.Shake, () => {
. . # . . . . # . .
`) `)
} }
if (randomArrow = 1) { if (randomArrow == 1) {
basic.showLeds(` basic.showLeds(`
. . # . . . . # . .
. # # . . . # # . .
@ -47,7 +47,7 @@ Modify the random number generator so that it can include new arrows we will cre
```blocks ```blocks
input.onGesture(Gesture.Shake, () => { input.onGesture(Gesture.Shake, () => {
let randomArrow = Math.random(8) let randomArrow = Math.random(8)
if (randomArrow = 3) { if (randomArrow == 3) {
basic.showLeds(` basic.showLeds(`
. . # . . . . # . .
. # # # . . # # # .
@ -56,7 +56,7 @@ input.onGesture(Gesture.Shake, () => {
. . # . . . . # . .
`) `)
} }
if (randomArrow = 2) { if (randomArrow == 2) {
basic.showLeds(` basic.showLeds(`
. . # . . . . # . .
. . # . . . . # . .
@ -65,7 +65,7 @@ input.onGesture(Gesture.Shake, () => {
. . # . . . . # . .
`) `)
} }
if (randomArrow = 1) { if (randomArrow == 1) {
basic.showLeds(` basic.showLeds(`
. . # . . . . # . .
. # # . . . # # . .
@ -90,7 +90,7 @@ Let's add more arrows that point diagonally.
```blocks ```blocks
input.onGesture(Gesture.Shake, () => { input.onGesture(Gesture.Shake, () => {
let randomArrow = Math.random(8) let randomArrow = Math.random(8)
if (randomArrow = 7) { if (randomArrow == 7) {
basic.showLeds(` basic.showLeds(`
. . # . . . . # . .
. # # # . . # # # .
@ -99,7 +99,7 @@ input.onGesture(Gesture.Shake, () => {
. . # . . . . # . .
`) `)
} }
if (randomArrow = 6) { if (randomArrow == 6) {
basic.showLeds(` basic.showLeds(`
. . # . . . . # . .
. . # . . . . # . .
@ -108,7 +108,7 @@ input.onGesture(Gesture.Shake, () => {
. . # . . . . # . .
`) `)
} }
if (randomArrow = 5) { if (randomArrow == 5) {
basic.showLeds(` basic.showLeds(`
. . # . . . . # . .
. # # . . . # # . .
@ -118,7 +118,7 @@ input.onGesture(Gesture.Shake, () => {
`) `)
} }
if (randomArrow = 4) { if (randomArrow == 4) {
basic.showLeds(` basic.showLeds(`
. . # . . . . # . .
. . . # . . . . # .
@ -129,7 +129,7 @@ input.onGesture(Gesture.Shake, () => {
} }
if (randomArrow = 3) { if (randomArrow == 3) {
basic.showLeds(` basic.showLeds(`
# # # # # # # # # #
# # # # . # # # # .
@ -139,7 +139,7 @@ input.onGesture(Gesture.Shake, () => {
`) `)
} }
if (randomArrow = 2) { if (randomArrow == 2) {
basic.showLeds(` basic.showLeds(`
# # # # # # # # # #
# # # # # # # # # #
@ -149,7 +149,7 @@ input.onGesture(Gesture.Shake, () => {
`) `)
} }
if (randomArrow = 1) { if (randomArrow == 1) {
basic.showLeds(` basic.showLeds(`
# . . . # # . . . #
# # . # . # # . # .