updated getting started

This commit is contained in:
Peli de Halleux 2016-06-02 12:32:13 -07:00
parent c5c0103573
commit d5628c08c8

View File

@ -5,12 +5,12 @@ Are you ready to build cool BBC micro:bit programs?
Here are some challenges for you. Unscramble the blocks in the editor Here are some challenges for you. Unscramble the blocks in the editor
to make real programs that work! to make real programs that work!
### Blinky face ### Happy face
You should see three blocks in the editor to the left. You should see three blocks in the editor to the left.
These are a block with a smiley face, ... These are a block with a smiley face, ...
```shuffle ```blocks
basic.forever(() => { basic.forever(() => {
basic.showLeds(` basic.showLeds(`
. . . . . . . . . .
@ -29,65 +29,18 @@ basic.forever(() => {
}); });
``` ```
### Show LEDs
Draw something in the editor with this block. You can draw another
smiley face, or try something else.
```shuffle
basic.showLeds(`
. . . . .
. # . # .
. . . . .
# . . . #
. # # # .
`)
```
To move your program from your computer to the BBC micro:bit: To move your program from your computer to the BBC micro:bit:
* Connect your micro:bit to the computer with the USB cable. * Connect your micro:bit to the computer with the USB cable.
* Click **Compile**. * Click **Compile**.
* Drag and drop the new file whose name ends in **.hex** into the **MICROBIT** window. * Drag and drop the new file whose name ends in **.hex** into the **MICROBIT** window.
* Wait until the yellow light stops blinking! * Wait until the yellow light stops blinking!
### Show animation forever ### Happy unhappy face
Show one picture after another by snapping blocks together to create an Let's draw an unhappy face instead of the blank screen. Click on the dots in the ``show leds`` block
animation (like a cartoon)! until it matches the blocks below.
```blocks ```blocks
basic.showLeds(`
. . . . .
. # . # .
. . . . .
# . . . #
. # # # .
`)
basic.showLeds(`
. . . . .
. # . # .
. . . . .
. # # # .
# . . . #
`)
```
To move your program from your computer to the BBC micro:bit:
* Connect your micro:bit to the computer with the USB cable.
* Click **Compile**.
* Drag and drop the new file whose name ends in **.hex** into the **MICROBIT** window.
* Wait until the yellow light stops blinking!
### Repeat Forever
Make an animation that never stops with the ``forever`` block.
Unscramble these blocks in the editor to make an animation that first
shows a happy face, then an unhappy face, then a happy face, and never
stops.
```shuffle
basic.forever(() => { basic.forever(() => {
basic.showLeds(` basic.showLeds(`
. . . . . . . . . .
@ -106,40 +59,70 @@ basic.forever(() => {
}); });
``` ```
To move your program from your computer to the BBC micro:bit:
* Connect your micro:bit to the computer with the USB cable.
* Click **Compile**.
* Drag and drop the new file whose name ends in **.hex** into the **MICROBIT** window.
* Wait until the yellow light stops blinking!
### Your turn! ### Your turn!
You can also change the pictures to make your own animation. Pile up more ``show leds`` blocks to create your animation! Create an animation with at least 5 images.
Make your own awesome animation with the ``show leds`` and ``forever``
blocks. ```blocks
basic.forever(() => {
basic.showLeds(`
. . . . .
. # . # .
. . . . .
# . . . #
. # # # .
`)
basic.showLeds(`
. . . . .
. # . # .
. . . . .
. # # # .
# . . . #
`)
basic.showLeds(`
. . . . .
. # . # .
. . . . .
# # # # #
. . . . .
`)
});
```
To move your program from your computer to the BBC micro:bit:
* Connect your micro:bit to the computer with the USB cable.
* Click **Compile**.
* Drag and drop the new file whose name ends in **.hex** into the **MICROBIT** window.
* Wait until the yellow light stops blinking!
#### ~hint #### ~hint
You can make your animation longer if you use more than two pictures. You can find the ``show leds`` block under the **Basic** category.
#### ~ #### ~
### Button A and B ### Button A and B
This program will show the word `banana` on the LED This program will show the word `banana` on the LED
screen when you press button `B`. screen when you press button `A`.
```blocks ```blocks
input.onButtonPressed(Button.B, () => { input.onButtonPressed(Button.A, () => {
basic.showString("banana"); basic.showString("banana");
}); });
``` ```
Now try to unscramble these blocks in the editor so that the micro:bit Now try to unscramble these blocks in the editor so that the micro:bit
shows **YES** when you press button `A` and **NO** when when you press shows **apple** when you press button `B`.
button `B`. All of the blocks under `on button A pressed` or
`on button B pressed` should run when you press that button.
```shuffle ```shuffle
input.onButtonPressed(Button.A, () => {
basic.showString("YES");
});
input.onButtonPressed(Button.B, () => { input.onButtonPressed(Button.B, () => {
basic.showString("NO"); basic.showString("apple");
}); });
``` ```