This commit is contained in:
Ron Hale-Evans 2016-05-26 16:52:33 -07:00
Родитель 8af6d640d3 5553fb93bb
Коммит 273e23095b
91 изменённых файлов: 184 добавлений и 214 удалений

2
.gitignore поставляемый
Просмотреть файл

@ -1,4 +1,6 @@
node_modules
yotta_modules
yotta_targets
built
typings
tmp

Просмотреть файл

@ -34,7 +34,7 @@
* [Rock Paper Scissors](/lessons/rock-paper-scissors), create the classic game of rock paper scissors with if statement
* [Truth or Dare](/lessons/truth-or-dare), a game that forces each player to reveal a secret or do something funny with if statement
* [Spinner](/lessons/spinner), spin the arrow with multiple if statements
* [Die Roll](/lessons/die-roll), spin with more if statements
* [Dice Roll](/lessons/dice-roll), spin with more if statements
* [Looper](/lessons/looper), display a series of numbers with a for loop index
* [Strobe Light](/lessons/strobe-light), develop shapes with a nested for loops
* [Temperature](/lessons/temperature), get the ambient temperature (degree Celsius °C)

Просмотреть файл

@ -1,8 +1,6 @@
# answering machine blocks lesson
create an answering machine on the BBC micro:bit #docs
### @video td/videos/answering-machine-0
Create an answering machine on the BBC micro:bit
## Topic
@ -25,12 +23,8 @@ Learn how to creating a message with a **string**, `show string` to write your m
```cards
basic.showString('Hi!')
input.onButtonPressed(Button.A, () => {})
```
* **on button pressed** : [read more...](/reference/input/on-button-pressed)
## Objectives
* learn how to show a string on the LED screen one character at a time

Просмотреть файл

@ -4,7 +4,6 @@ Learn to create an answering machine on the micro:bit
### ~avatar avatar
### @video td/videos/answering-machine-0
Let's learn how to create an answering machine!

Просмотреть файл

@ -12,8 +12,6 @@ basic.showString("ASK ME A QUESTION")
### Challenge 1
### @video td/videos/answering-machine-1
Now we need to reply after someone asks micro:bit a yes or no question. We want to respond `YES` when button `A` is pressed. Add a condition for button `A` and inside it show the string `YES`.
```blocks
@ -27,8 +25,6 @@ input.onButtonPressed(Button.A, () => {
### Challenge 2
### @video td/videos/answering-machine-2
What if micro:bit's answer to the question is no? Let's have `NO` be displayed when button `B` is pressed. Add a condition for button `B` and inside it show the string `NO`.
```blocks

Просмотреть файл

@ -1,8 +1,6 @@
# beautiful image lesson
display beautiful images on the BBC micro:bit.
### @video td/videos/beautiful-image-0
Display beautiful images on the BBC micro:bit.
## Topic

Просмотреть файл

@ -4,8 +4,6 @@ Generate and show a beautiful image.
### ~avatar avatar
### @video td/videos/beautiful-image-0
Let's learn how to show an image on the LED screen.
### ~

Просмотреть файл

@ -18,8 +18,6 @@ basic.showLeds(`
### Challenge 1
### @video td/videos/beautiful-image-1-2
Now show an new image that will display on the micro:bit.
```blocks

Просмотреть файл

@ -2,8 +2,6 @@
Learn how to create a blinking LED.
### @video td/videos/blink-0
## Topic
Plot
@ -30,7 +28,6 @@ basic.pause(100)
basic.forever(() => {})
```
## Objectives
* learn how to turn on LED lights on the LED screen

Просмотреть файл

@ -4,7 +4,15 @@ Turn an LED on and off with forever
### ~avatar avatar
### @video td/videos/blink-0
```sim
basic.forever(() => {
led.plot(2, 2)
basic.pause(500)
led.unplot(2, 2)
basic.pause(500)
})
```
Let's build a blinking light!
### ~
@ -43,7 +51,6 @@ basic.forever(() => {
led.unplot(2, 2)
basic.pause(500)
})
```
### ~avatar boothing

Просмотреть файл

@ -17,8 +17,6 @@ basic.forever(() => {
### Challenge 1
### @video td/videos/blink-1
Let's display a "smiley face" on the screen! We'll start by plotting the eyes.
Add `plot(1,1)` and `plot(3,1)` under `plot(2,2)` ; then add `unplot(1,1)`, `unplot(3,1)` and `unplot(2,2)` after `pause`. When you're ready, don't forget to run your code to try it out!
@ -38,8 +36,6 @@ basic.forever(() => {
### Challenge 2
### @video td/videos/blink-2
Let's add the code to plot the mouth by using `plot` and `unplot` to the following coordinates: (1,4), (2,4) and (3,4). When you're ready, don't forget to run your code to try it out!
```blocks
@ -63,8 +59,6 @@ basic.forever(() => {
### Challenge 3
### @video td/videos/blink-3
Let's keep using `plot` to convert the mouth into a smiley face.
```` bitmatrix

Просмотреть файл

@ -2,8 +2,6 @@
A game to catch eggs in a basket.
### @video td/videos/catch-the-egg-game-0
## Topic
Variables

Просмотреть файл

@ -108,8 +108,6 @@ basic.forever(() => {
### 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

Просмотреть файл

@ -2,8 +2,6 @@
create a die on the BBC micro:bit.
### @video td/videos/compass-0
## Topic
If (Conditionals)

Просмотреть файл

@ -2,8 +2,6 @@
Learn how to create a counter with with on button pressed.
### @video td/videos/counter-0
## Topic
Variables

Просмотреть файл

@ -4,8 +4,6 @@ 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!
### ~

Просмотреть файл

@ -16,8 +16,6 @@ input.onButtonPressed(Button.A, () => {
### Challenge 1
### @video td/videos/counter-1-2
Let's add the code to `count` when `B` is pressed. Add an event handler with `on button pressed(B)` then add the code to `count`.
@ -33,7 +31,6 @@ input.onButtonPressed(Button.B, () => {
})
```
### Challenge 3
Now let's try to reset the counter when the micro:bit is shaken. You will need to register an event handler with `on shake`.

Просмотреть файл

@ -1,8 +1,6 @@
# die roll lesson
# dice roll lesson
create a die on the BBC micro:bit.
### @video td/videos/die-roll-0
Create a dice on the BBC micro:bit.
## Topic
@ -10,10 +8,10 @@ If (Conditionals)
## Quick Links
* [activity](/lessons/die-roll/activity)
* [challenges](/lessons/die-roll/challenges)
* [quiz](/lessons/die-roll/quiz)
* [quiz answers](/lessons/die-roll/quiz-answers)
* [activity](/lessons/dice-roll/activity)
* [challenges](/lessons/dice-roll/challenges)
* [quiz](/lessons/dice-roll/quiz)
* [quiz answers](/lessons/dice-roll/quiz-answers)
## Prior learning/place of lesson in scheme of work

Просмотреть файл

@ -1,12 +1,10 @@
# die roll activity
# dice roll activity
Create a die on the micro:bit
Create a dice on the micro:bit
### ~avatar avatar
### @video td/videos/die-roll-0
Welcome! This tutorial will help you create a die. Let's get started!
Welcome! This tutorial will help you create a dice. Let's get started!
### ~
@ -19,7 +17,7 @@ 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**.
We need to show a random value from 1 to 6 on our dice. So let's make a local variable called **roll**.
```blocks
input.onGesture(Gesture.Shake, () => {
@ -27,7 +25,7 @@ input.onGesture(Gesture.Shake, () => {
})
```
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.
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 dice that shows 6.
```blocks
@ -45,7 +43,7 @@ input.onGesture(Gesture.Shake, () => {
```
Let's use an `else if` condition for if **roll** is 4. If **roll** is 4 we can show 5 dots on the die.
Let's use an `else if` condition for if **roll** is 4. If **roll** is 4 we can show 5 dots on the dice.
```blocks
@ -72,7 +70,7 @@ input.onGesture(Gesture.Shake, ()=> {
```
Now we need to repeat the same steps for if **roll** is 3. If **roll** is 3 we will show `4` on the die.
Now we need to repeat the same steps for if **roll** is 3. If **roll** is 3 we will show `4` on the dice.
```blocks
@ -106,7 +104,7 @@ input.onGesture(Gesture.Shake, () => {
```
Let's also repeat these steps to show the 3, 2, and 1 on the die. We are almost done with our die!
Let's also repeat these steps to show the 3, 2, and 1 on the dice. We are almost done with our dice!
```blocks
input.onGesture(Gesture.Shake, () => {
@ -165,7 +163,7 @@ input.onGesture(Gesture.Shake, () => {
### ~avatar avatar
Excellent, you're ready to continue with the [challenges](/lessons/die-roll/challenges)!
Excellent, you're ready to continue with the [challenges](/lessons/dice-roll/challenges)!
### ~

Просмотреть файл

@ -1,10 +1,10 @@
# die roll challenges
# dice roll challenges
Create a die on the micro:bit.
Create a dice on the micro:bit.
## Before we get started
Complete the following [guided tutorial](/lessons/die-roll/activity), your code should look like this:
Complete the following [guided tutorial](/lessons/dice-roll/activity), your code should look like this:
```blocks
input.onGesture(Gesture.Shake, () => {
@ -62,7 +62,7 @@ input.onGesture(Gesture.Shake, () => {
### Challenge 1
Modify the line of code with `pick random` so that only number 1-4 can appear on the die.
Modify the line of code with `pick random` so that only number 1-4 can appear on the dice.
```blocks
@ -121,7 +121,7 @@ input.onGesture(Gesture.Shake, () => {
### Challenge 2
Let's make a trick die! Modify the line of code with `pick 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.
Let's make a trick dice! Modify the line of code with `pick random` so that only numbers 3-6 can appear on the dice. Also note that we need to ensure `roll = 0` when only 1 dot is shown on the BBC micro:bit.
```blocks
input.onGesture(Gesture.Shake, () => {

Просмотреть файл

@ -1,8 +1,8 @@
# die roll quiz answers
# dice roll quiz answers
Create a die when the BBC micro:bit is shaken
Create a dice when the BBC micro:bit is shaken
These are the answers to the [die roll quiz](/lessons/die-roll/quiz).
These are the answers to the [dice roll quiz](/lessons/dice-roll/quiz).
## 1. Create a variable named 'roll' that will be randomly assigned to a number between 0 and 5.

Просмотреть файл

@ -1,12 +1,12 @@
# die roll quiz
# dice roll quiz
Create a die when the BBC micro:bit is shaken
Create a dice when the BBC micro:bit is shaken
## Name
## Directions
Use this activity document to guide your work in the [die roll tutorial](/lessons/die-roll/activity).
Use this activity document to guide your work in the [dice roll tutorial](/lessons/dice-roll/activity).
Answer the questions while completing the tutorial. Pay attention to the dialogues!

Просмотреть файл

@ -1,8 +1,6 @@
# digi yoyo lesson
create a counter with a while loop.
### @video td/videos/digi-yoyo-0
Create a counter with a while loop.
## Topic

Просмотреть файл

@ -4,8 +4,6 @@ Create a counter with a while loop.
### ~avatar avatar
### @video td/videos/digi-yoyo-0
Welcome! This tutorial will teach how to create a counter with a while loop. Let's get started!
### ~

Просмотреть файл

@ -40,8 +40,6 @@ while (count > 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`!

Просмотреть файл

@ -2,8 +2,6 @@
Learn how to create LED images with a global variable.
### @video td/videos/flashing-heart-0
## Topic
Pause

Просмотреть файл

@ -4,8 +4,6 @@ Control images with a variable.
### ~avatar avatar
### @video td/videos/flashing-heart-0
In this activity, you will learn how to blink an image on the LED screen.
### ~

Просмотреть файл

@ -25,8 +25,6 @@ basic.forever(() => {
### 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 block between the last line and the end loop. Add a `show LEDs` block and then add a `pause` of 500 milliseconds.
@ -60,8 +58,6 @@ basic.forever(() => {
### 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 add a `clear screen` block and then add a `pause` block of 500 milliseconds under the new code we added in Challenge 1.

Просмотреть файл

@ -2,8 +2,6 @@
Learn how to create a counter with with on button pressed.
### @video td/videos/counter-0
## Topic
Game Library

Просмотреть файл

@ -1,13 +1,5 @@
# game counter activity
Turn an LED on and off with forever loop
### ~avatar avatar
### @video td/videos/counter-0
### ~
Have you ever tried to create a game counter? The concept is fairly simply: increase the game `score` with `on button pressed` .
Let's start by adding `on button (A) pressed` will run each time the user presses A. Let's add a line of code that increments `score` by `1`.

Просмотреть файл

@ -15,8 +15,6 @@ input.onButtonPressed(Button.A, () => {
### Challenge 1
### @video td/videos/counter-1-2
Let's add the code to `score` when `B` is pressed. Add an event handler with `on button (B) pressed` then add the code to `score`.

Просмотреть файл

@ -2,8 +2,6 @@
Learn to create a random number with input from button A.
### @video td/videos/guess-the-number-0
## Topic
Math - Pick Random

Просмотреть файл

@ -4,8 +4,6 @@ Guess the number with math random.
### ~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!
### ~

Просмотреть файл

@ -15,8 +15,6 @@ input.onButtonPressed(Button.A, () => {
### 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.
```blocks

Просмотреть файл

@ -2,8 +2,6 @@
### ~avatar avatar
### @video td/videos/guess-the-number-0
This tutorial will help you create a guess the number game! Let's get started!
### ~

Просмотреть файл

@ -2,8 +2,6 @@
Learn to control blinking LEDs.
### @video td/videos/looper-0
## Topic
For Loop

Просмотреть файл

@ -1,13 +1,5 @@
# looper blocks activity
Display a series of numbers with a for loop.
### ~avatar avatar
### @video td/videos/looper-0
### ~
Welcome! This activity will teach how to display a series of numbers for a for loop. Let's get started!
Let's create a for loop where `0` is the loop's starting value, `i` is the index variable, and `5` is the ending value. The index variable `i` starts at 0 and increases by 1 each time through the loop. The loop ends when `i = 5`.

Просмотреть файл

@ -20,8 +20,6 @@ for (let i = 0; i < 6; i++) {
### Challenge 1
### @video td/videos/looper-1
What if we want to count up to lucky number 7 instead? Let's do that by changing the ending value to `7` instead of `5`.
@ -37,8 +35,6 @@ for (let i = 0; i < 8; i++) {
### Challenge 2
### @video td/videos/looper-2
What about 9? Let's do that by changing the ending value to `9`.
```blocks
@ -55,8 +51,6 @@ for (let i = 0; i < 10; i++) {
### Challenge 3
### @video td/videos/looper-3
Now let's start counting from `3` instead! Our for loop will always start at `0` so we simply add `3` to the `i` variable when passing it to `show number`.
```blocks
@ -72,8 +66,6 @@ Run it on the simulator!
### Challenge 4
### @video td/videos/looper-4
Now, let's **count down from 9**. Change the line `show number(i + 2, 150)` to `show number(9 - i, 150)`.
```blocks

Просмотреть файл

@ -1,8 +1,6 @@
# love meter blocks lesson
create a love meter with the BBC micro:bit.
### @video td/videos/love-meter-0
Create a love meter with the BBC micro:bit.
## Topic

Просмотреть файл

@ -4,8 +4,6 @@ Create a love meter with the micro:bit
### ~avatar avatar
### @video td/videos/love-meter-0
Welcome! This activity will help you create a love meter with the micro:bit. Let's get started!
### ~

Просмотреть файл

@ -45,8 +45,6 @@ input.onPinPressed(TouchPin.P0, () => {
### Challenge 3
### @video td/videos/love-meter-3
**If** the rating is between 4 and 7, display the text "MEDIOCRE!" **else** display the text "MATCHED!"
```blocks

Просмотреть файл

@ -1,8 +1,6 @@
# lucky 7 blocks lesson
show a number on the LED screen.
### @video td/videos/lucky-7-0
Show a number on the LED screen.
## Topic

Просмотреть файл

@ -4,8 +4,6 @@ Show a number on the LED screen.
### ~avatar avatar
### @video td/videos/lucky-7-0
Let's learn how to show the lucky number 7 on the LED screen.
### ~

Просмотреть файл

@ -21,8 +21,6 @@ basic.pause(500)
### Challenge 2
### @video td/videos/lucky-7-1-2
What about other multiples of 7? Let's display the next multiple of 7 on the screen!
```blocks

Просмотреть файл

@ -2,7 +2,7 @@
show an image that points up when the logo is up.
### @video td/videos/magic-logo-0
## Topic

Просмотреть файл

@ -4,8 +4,6 @@ Show an image that points up when the logo is up.
### ~avatar avatar
### @video td/videos/magic-logo-0
Welcome! This tutorial will help you display an arrow pointing toward the logo! Let's get started.
### ~

Просмотреть файл

@ -24,8 +24,6 @@ input.onLogoUp(() => {
How about when the logo is down? We should display an arrow pointing downward!
### @video td/videos/magic-logo-1-2
```blocks
input.onLogoUp(() => {
basic.showLeds(`

Просмотреть файл

@ -2,8 +2,6 @@
change the brightness of the BBC micro:bit.
### @video td/videos/night-light-0
## Topic
Set Brightness

Просмотреть файл

@ -4,8 +4,6 @@ Change the brightness of the micro:bit.
### ~avatar avatar
### @video td/videos/night-light-0
Welcome! This tutorial will teach you how to change the brightness of the micro:bit. Let's get started!
### ~

Просмотреть файл

@ -23,7 +23,7 @@ input.onButtonPressed(Button.A, () => {
```
### Challenge 1
### @video td/videos/night-light-2
What if we want to turn off all the LEDs? Let's do this by setting the brightness to `0` when button `B` is pressed. Add an event handler with `on button pressed(B)` add `set brightness(0)` to turn off the LEDs.

Просмотреть файл

@ -55,7 +55,7 @@ input.onButtonPressed(Button.B, () => {
### Challenge 2
### @video td/videos/offset-image-2
Now we want to make sure that the button does not go off the screen to the right. Add a new line that checks to see if offset = 5 after button `A` is pressed.

Просмотреть файл

@ -2,7 +2,7 @@
a game against the BBC micro:bit.
### @video td/videos/rock-paper-scissors-0
## Topic

Просмотреть файл

@ -4,7 +4,7 @@ A classic game against the micro:bit.
### ~avatar avatar
### @video td/videos/rock-paper-scissors-0
Welcome! This tutorial will help you create a game of rock paper scissors with the micro:bit. Let's get started!

Просмотреть файл

@ -93,7 +93,7 @@ input.onButtonPressed(Button.A, () => {
### Challenge 2
### @video td/videos/rotation-animation-1-and-2
Now that we have the on button pressed condition, let's make the animation stop rotating by setting the rotating global variable to false when button `A` is pressed.

Просмотреть файл

@ -2,7 +2,7 @@
clear the screen by pressing button "A".
### @video td/videos/screen-wipe-0
## Topic

Просмотреть файл

@ -4,7 +4,7 @@ Clear the screen by pressing buttons on the micro:bit
### ~avatar avatar
### @video td/videos/screen-wipe-0
This activity will teach how to clear the screen by pressing button A on the micro:bit.

Просмотреть файл

@ -85,7 +85,7 @@ input.onButtonPressed(Button.B, () => {
### Challenge 2
### @video td/videos/screen-wipe-2
Replay the animation when the "B" button is pressed placing the `show LEDs` block on the canvas.

Просмотреть файл

@ -2,7 +2,7 @@
design a blinking image lesson #docs
### @video td/videos/smiley-0
## Topic

Просмотреть файл

@ -4,7 +4,7 @@ Learn to design a blinking image.
### ~avatar avatar
### @video td/videos/smiley-0
Welcome! This tutorial will help you make a smiley face blink. Let's get started!

Просмотреть файл

@ -54,7 +54,7 @@ input.onButtonPressed(Button.A, () => {
### Challenge 2
### @video td/videos/smiley-2
Now, we want to show a frowny face when this button is pressed. Let's show the LEDs.

Просмотреть файл

@ -2,7 +2,7 @@
design a blinking rectangle animation.
### @video td/videos/snowflake-fall-0
## Topic

Просмотреть файл

@ -4,7 +4,7 @@ design a blinking rectangle animation.
### ~avatar avatar
### @video td/videos/snowflake-fall-0
Welcome! This tutorial will teach how design a **snowfall animation**. Let's get started!

Просмотреть файл

@ -27,7 +27,7 @@ basic.forever(() => {
### Challenge 1
### @video td/videos/snowflake-fall-1
To finalize our snowflake fall, let's add a different snowflake pattern.

Просмотреть файл

@ -2,7 +2,7 @@
code a speed game by declaring Booleans on the BBC micro:bit.
### @video td/videos/speed-button-3
## Topic

Просмотреть файл

@ -63,7 +63,7 @@ input.onButtonPressed(Button.A, () => {
### Challenge 3
### @video td/videos/speed-button-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.
@ -91,7 +91,7 @@ input.onButtonPressed(Button.A, () => {
### Challenge 4
### @video td/videos/speed-button-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 5000 milliseconds to 6000 milliseconds will make the difficulty easier.

Просмотреть файл

@ -2,7 +2,7 @@
a spin the BBC micro:bit game with the input on shake.
### @video td/videos/spinner-0
## Topic

Просмотреть файл

@ -4,7 +4,7 @@ Create an arrow that randomly points to a player.
### ~avatar avatar
### @video td/videos/spinner-0
### ~

Просмотреть файл

@ -2,7 +2,7 @@
Learn how to create a blinking LED script.
### @video td/videos/strobe-light-0
## Topic

Просмотреть файл

@ -4,7 +4,7 @@ Develop shapes with a for loop.
### ~avatar avatar
### @video td/videos/strobe-light-0
Welcome! This guided tutorial will teach how to develop shapes with a for loop. Let's get started!

Просмотреть файл

@ -19,7 +19,7 @@ for (let i = 0; i < 5; i++) {
### Challenge 1
### @video td/videos/strobe-light-1
Make the LEDs light up faster by changing the **pause** from 200 to 100 milliseconds:
@ -36,7 +36,7 @@ for (let i = 0; i < 5; i++) {
### Challenge 2
### @video td/videos/strobe-light-2
Make the board light up by rows instead of by columns by swapping the `i` and `j` variables in `plot(i, j)`.
@ -53,7 +53,7 @@ for (let i = 0; i < 5; i++) {
### Challenge 3
### @video td/videos/strobe-light-ultimate
Now that all the LEDs are lit up, let's make them turn off by reversing the strobe light pattern! You can use `unplot` to turn off a single LED.

Просмотреть файл

@ -22,7 +22,7 @@ The lesson plan maps to the Progressions Pathways, Computing Curriculum, and Qui
Expand your knowledge of programming with lots of great step-by-step activities. All the lessons come with instructions that will drive the students to a complete, functional code. These activities are very directive to make sure that students keep progressing. When the activities are over, additional challenges are given to advance code through printed instructions. An activity contains supporting videos as shown with the [blink activity](/lessons/blink/activity).
### @video td/videos/blink-0
3) Quiz

Просмотреть файл

@ -2,7 +2,7 @@
create a love meter with the BBC micro:bit.
### @video td/videos/truth-or-dare-0
## Topic

Просмотреть файл

@ -4,7 +4,7 @@ A multi-player game that forces each player to reveal a secret or something funn
### ~avatar avatar
### @video td/videos/truth-or-dare-0
Welcome! This tutorial will teach how to program a game of truth or dare on the micro:bit. Let's get started!

Просмотреть файл

@ -2,7 +2,7 @@
### ~avatar avatar
### @video td/videos/truth-or-dare-0
The *Truth or dare!* game works as follows: a player spins the BBC micro:bit on the table.
When the micro:bit stops spinning, the player pointed by the arrow (displayed on screen) must press the button "A"

Просмотреть файл

@ -2,7 +2,7 @@
measure the acceleration on the micro:bit in the "z" direction.
### @video td/videos/zoomer-0
## Topic

Просмотреть файл

@ -4,7 +4,7 @@ Measure the acceleration on the micro:bit in the "z" direction.
### ~avatar avatar
### @video td/videos/zoomer-0
### ~

Просмотреть файл

@ -14,7 +14,7 @@ basic.forever(() => {
```
### Challenge 1
### @video td/videos/zoomer-2
We'll modify the code to display the `x` acceleration if the `A` button is pressed. For that, we need to store `acceleration (x)` in a new variable `ax` and use a `button (A) is pressed` to detect if the button is pressed.

Просмотреть файл

@ -2,8 +2,37 @@
### ~avatar avatar
### @video td/videos/rock-paper-scissors-0
```sim
input.onGesture(Gesture.Shake, () => {
let img = Math.random(3)
if (img == 0) {
basic.showLeds(`
# # # # #
# . . . #
# . . . #
# . . . #
# # # # #
`)
} else if (img == 1) {
basic.showLeds(`
. . . . .
. # # # .
. # # # .
. # # # .
. . . . .
`)
} else {
basic.showLeds(`
# # . . #
# # . # .
. . # . .
# # . # .
# # . . #
`)
}
})
```
In this project, you will build a Rock Paper Scissors game with the BBC micro:bit.
You can play the game with a friend who has it on a micro:bit.
You can also play it with friends who are just using their hands.
@ -135,17 +164,15 @@ input.onGesture(Gesture.Shake, () => {
`)
} else {
basic.showLeds(`
. . . # #
# # . . #
# # . # .
. . # . .
# # . # .
. . . # #
# # . . #
`)
}
})
```
### ~hint

2
docs/static/microbit.simplified.svg поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

До

Ширина:  |  Высота:  |  Размер: 17 KiB

После

Ширина:  |  Высота:  |  Размер: 20 KiB

21
libs/microbit/enums.d.ts поставляемый
Просмотреть файл

@ -280,6 +280,27 @@ declare namespace led {
}
declare namespace pins {
}
declare enum SerialPin {
P0 = 7, // MICROBIT_ID_IO_P0
P1 = 8, // MICROBIT_ID_IO_P1
P2 = 9, // MICROBIT_ID_IO_P2
P8 = 15, // MICROBIT_ID_IO_P8
P12 = 19, // MICROBIT_ID_IO_P12
P13 = 20, // MICROBIT_ID_IO_P13
P14 = 21, // MICROBIT_ID_IO_P14
P15 = 22, // MICROBIT_ID_IO_P15
P16 = 23, // MICROBIT_ID_IO_P16
}
declare enum BaudRate {
//% block=115200
BaudRate115200 = 115200,
//% block=9600
BaudRate9600 = 9600,
}
declare namespace serial {
}

Просмотреть файл

@ -1,5 +1,24 @@
#include "ksbit.h"
enum class SerialPin {
P0 = MICROBIT_ID_IO_P0,
P1 = MICROBIT_ID_IO_P1,
P2 = MICROBIT_ID_IO_P2,
P8 = MICROBIT_ID_IO_P8,
P12 = MICROBIT_ID_IO_P12,
P13 = MICROBIT_ID_IO_P13,
P14 = MICROBIT_ID_IO_P14,
P15 = MICROBIT_ID_IO_P15,
P16 = MICROBIT_ID_IO_P16
};
enum class BaudRate {
//% block=115200
BaudRate115200 = 115200,
//% block=9600
BaudRate9600 = 9600
};
//% weight=2 color=30
namespace serial {
// note that at least one // followed by % is needed per declaration!
@ -34,4 +53,19 @@ namespace serial {
uBit.serial.eventOn(ManagedString(delimiters));
registerWithDal(MICROBIT_ID_SERIAL, MICROBIT_SERIAL_EVT_DELIM_MATCH, body);
}
}
/**
* Dynamically configuring the serial instance to use pins other than USBTX and USBRX.
* @param tx the new transmission pins
* @param rx the new reception pin
* @param baud the new baud rate. eg: 115200
*/
//% weight=10
//% help=serial/redirect
//% blockId=serial_redirect block="serial redirect to|TX %tx|RX %rx|at baud rate %rate"
//% blockExternalInputs=1
void redirect(SerialPin tx, SerialPin rx, BaudRate rate) {
uBit.serial.redirect((PinName)tx, (PinName)rx);
uBit.serial.baud((int)rate);
}
}

12
libs/microbit/shims.d.ts поставляемый
Просмотреть файл

@ -575,6 +575,18 @@ declare namespace serial {
//% weight=87
//% blockId=serial_writestring block="serial write string %text" shim=serial::writeString
function writeString(text: string): void;
/**
* Dynamically configuring the serial instance to use pins other than USBTX and USBRX.
* @param tx the new transmission pins
* @param rx the new reception pin
* @param baud the new baud rate. eg: 115200
*/
//% weight=10
//% help=serial/redirect
//% blockId=serial_redirect block="serial redirect to|TX %tx|RX %rx|at baud rate %rate"
//% blockExternalInputs=1 shim=serial::redirect
function redirect(tx: SerialPin, rx: SerialPin, rate: BaudRate): void;
}

Просмотреть файл

@ -2,8 +2,6 @@
scroll an image across the screen.
### @video td/videos/bounce-image-0
## Topic
Basic- Show Animation

Просмотреть файл

@ -24,8 +24,6 @@ basic.forever(() => {
### 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.
```
@ -60,9 +58,7 @@ input.onGesture(Gesture.Shake, () => {
}) // ***
```
**Challenge 3**
### @video td/videos/bounce-image-2-3
### Challenge 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!

Просмотреть файл

@ -2,8 +2,6 @@
a display of pet images for the BBC micro:bit.
### @video td/videos/digital-pet-0
## Topic
Functions

Просмотреть файл

@ -41,8 +41,6 @@ basic.forever(() => {
### 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.
```
@ -76,8 +74,6 @@ basic.forever(() => {
### 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`.
```
@ -97,8 +93,6 @@ basic.forever(() => {
### 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.
```

Просмотреть файл

@ -50,8 +50,6 @@ input.onGesture(Gesture.Shake, () => {
### 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.
```

Просмотреть файл

@ -4,8 +4,6 @@ These challenges will help you display a glowing image that fades in and out at
**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.
```
@ -37,9 +35,7 @@ basic.pause(1000) // ***
* Run the code to see if it works as expected.
**Challenge 2**
### @video vimeo/134674595
### Challenge 2
After the pause, let's add `led->fade in(2000)` so that we can create a glowing effect.

Просмотреть файл

@ -2,8 +2,6 @@
make a glowing sword.
### @video td/videos/glowing-sword-0
## Topic
Fade Out

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "pxt-microbit",
"version": "0.2.131",
"version": "0.2.133",
"description": "BBC micro:bit target for PXT",
"keywords": [
"JavaScript",
@ -29,6 +29,6 @@
"typescript": "^1.8.7"
},
"dependencies": {
"pxt-core": "0.2.140"
"pxt-core": "0.2.143"
}
}

Просмотреть файл

@ -438,6 +438,10 @@ namespace pxsim.serial {
let b = board();
b.bus.listen(DAL.MICROBIT_ID_SERIAL, DAL.MICROBIT_SERIAL_EVT_DELIM_MATCH, handler);
}
export function redirect(tx: number, rx: number, rate: number) {
// TODO?
}
}