merged microbit changes

This commit is contained in:
Peli de Halleux 2016-10-17 13:36:54 -07:00
commit a331a017b8
34 changed files with 270 additions and 90 deletions

View File

@ -13,20 +13,20 @@ export function deployCoreAsync(res: ts.pxtc.CompileResult) {
return getBitDrivesAsync() return getBitDrivesAsync()
.then(drives => { .then(drives => {
if (drives.length == 0) { if (drives.length == 0) {
let msg = "cannot find any drives to deploy to"; console.log("cannot find any drives to deploy to");
console.log(msg); return Promise.resolve(0);
return Promise.reject(new Error(msg));
} }
console.log(`copy ${ts.pxtc.BINARY_HEX} to ` + drives.join(", ")) console.log(`copy ${ts.pxtc.BINARY_HEX} to ` + drives.join(", "));
return Promise.map(drives, d => let writeHexFile = (filename: string) => {
writeFileAsync(d + ts.pxtc.BINARY_HEX, res.outfiles[ts.pxtc.BINARY_HEX]) return writeFileAsync(filename + ts.pxtc.BINARY_HEX, res.outfiles[ts.pxtc.BINARY_HEX])
.then(() => { .then(() => console.log("wrote hex file to " + filename));
console.log("wrote hex file to " + d) };
}))
}) return Promise.map(drives, d => writeHexFile(d))
.then(() => { }) .then(() => drives.length);
});
} }
function getBitDrivesAsync(): Promise<string[]> { function getBitDrivesAsync(): Promise<string[]> {

View File

@ -1,11 +1,40 @@
# crocodile clips # crocodile clips
The large holes at the bottom of the board are designed to attach alligator/crocodile clips. The large holes at the bottom of the board are designed to attach alligator/crocodile clips
Register an event that will execute whenever the user attaches one side of the crocodile clip to the `GND` pin, then connects and disconnects the unattached side of the crocodile clip to pin `0`, `1`, or `2`. to create electrical circuit with other components.
### Example: on pin pressed with random numbers # ~hint
This example displays a random number every time the crocodile clip holds `GND` then connects and disconnects the `P0` pin. Each time the crocodile clip is firmly connected and disconnected from pin `P0`, the micro:bit will return a random Number between 0 and the parameter limit **No crocodile clips!?!?!** Use wires or Aluminium foil! [Read more...](/device/foil-circuits)
# ~
## Connecting Crocodile Clips
The hole for ``P0`` and ``GND`` allow to grab the board on the side which makes for a great grip.
![](/static/mb/device/croc-clips/crocclipsclamped.jpg)
Pass one jaw in the hole and grab the side of the board with the other jaw.
![](/static/mb/device/croc-clips/sideclamp.jpg)
For the center holes, ``P1`` and ``P2``, you can also grab the bottom of the board but they are a bit harder to grip.
You can also grip the board between the jaws. In which case, you will want to make sure to avoid overlapping the jaws
with the other pins as it will create short-circuit in the board.
![](/static/mb/device/croc-clips/badclamp.jpg)
Adding a little tape helps keeping the crocodile clips in place.
![](/static/mb/device/croc-clips/frontclamp.jpg)
## Example: on pin pressed with random numbers
This example displays a random number every time the crocodile clip holds `GND` then connects and disconnects the `P0` pin.
Each time the crocodile clip is firmly connected and disconnected from pin `P0`, the micro:bit will return a random Number between 0 and the parameter limit.
```blocks ```blocks
input.onPinPressed(TouchPin.P0, () => { input.onPinPressed(TouchPin.P0, () => {
@ -13,11 +42,6 @@ input.onPinPressed(TouchPin.P0, () => {
}) })
``` ```
### Connecting Crocodile Clips ## See also
![](/static/mb/crocodile-clips-2.jpg)
### See also
[micro:bit pins](/device/pins), [pin is pressed](/reference/input/pin-is-pressed), [analog read pin](/reference/pins/analog-read-pin), [analog write pin](/reference/pins/analog-write-pin), [digital read pin](/reference/pins/digital-read-pin), [digital write pin](/reference/pins/digital-write-pin)
[micro:bit pins](/device/pins)

View File

@ -1,7 +1,5 @@
# Error codes # Error codes
The micro:bit error codes
Your micro:bit may encounter a situation that prevents it from running your code. When this happens, a frowny face will appear on your micro:bit screen (see picture) followed by an error number. Your micro:bit may encounter a situation that prevents it from running your code. When this happens, a frowny face will appear on your micro:bit screen (see picture) followed by an error number.
Below is a list of error numbers and what they mean: Below is a list of error numbers and what they mean:

View File

@ -0,0 +1,52 @@
# foil circuits
The large holes at the bottom of the board are designed to attach alligator/crocodile clips
to create electrical circuit with other components.
If you do not have crocodile clips at hand, dyou can use wires or even Aluminium foil to acheive the same result.
We will show you how to connect the micro:bit to headphones using Alumunium foil and tape.
https://youtu.be/mhXYyPuvpz0
### Materials
* micro:bit and battery pack (you can also power it via USB)
* a small piece of cardboard
* Aluminium foil
* tape
### Assembly instructions
Tape the micro:bit and battery pack to the card board. Make sure to remove the batteries while you are building your circuit.
![](/static/mb/device/croc-clips/microbitattached.jpg)
Cut the thinest strip of foil possible and roll it into a cable. You can also try to fold, whatever works for you.
Build two of those wires.
![](/static/mb/device/croc-clips/foilcut.jpg)
Place the foil wire on the ``GND`` pin and attach with a piece of tape. Press hard to get the best connection between
the foil and the pin board. Make sure the foil is not overlapping with the other pins!
![](/static/mb/device/croc-clips/groundconnected.jpg)
Place the second wire on the ``P0`` pin the same way. Make sure the wire does not overlap with the other pins!
![](/static/mb/device/croc-clips/microbitconnect.jpg)
Tape the headphone jack connector to the cardboard and roll the wire coming from ``GND`` around the metal base.
Make sure the wire does not touch the other metal rings on the jack.
![](/static/mb/device/croc-clips/jackground.jpg)
Tape the second wire on the head of the jack connector.
![](/static/mb/device/croc-clips/jackconnect.jpg)
![](/static/mb/device/croc-clips/foilcircuit.jpg)
## See also
[micro:bit pins](/device/pins)

View File

@ -7,11 +7,12 @@
```sim ```sim
basic.forever(() => { basic.forever(() => {
basic.showLeds(` basic.showLeds(`
. # . # . . # . # .
# # # # # # # # # #
# # # # # # # # # #
. # # # . . # # # .
. . # . .`); . . # . .`
);
basic.pause(500); basic.pause(500);
basic.clearScreen(); basic.clearScreen();
basic.pause(500); basic.pause(500);
@ -29,11 +30,12 @@ Use [show leds](/reference/basic/show-leds) and make your code look like this:
```blocks ```blocks
basic.showLeds(` basic.showLeds(`
. # . # . . # . # .
# # # # # # # # # #
# # # # # # # # # #
. # # # . . # # # .
. . # . .`); . . # . .`
);
``` ```
## Step 2 ## Step 2
@ -42,11 +44,11 @@ Add a [pause](/reference/basic/pause) to wait and [clear screen](/reference/basi
```blocks ```blocks
basic.showLeds(` basic.showLeds(`
. # . # . . # . # .
# # # # # # # # # #
# # # # # # # # # #
. # # # . . # # # .
. . # . .`); . . # . .`);
basic.pause(500); basic.pause(500);
basic.clearScreen(); basic.clearScreen();
``` ```
@ -58,11 +60,12 @@ Put a [forever loop](/reference/basic/forever) around it.
```blocks ```blocks
basic.forever(() => { basic.forever(() => {
basic.showLeds(` basic.showLeds(`
. # . # . . # . # .
# # # # # # # # # #
# # # # # # # # # #
. # # # . . # # # .
. . # . .`); . . # . .`
);
basic.pause(500); basic.pause(500);
basic.clearScreen(); basic.clearScreen();
}) })
@ -75,11 +78,12 @@ Add a [pause](/reference/basic/pause) to wait after clearing the screen.
```blocks ```blocks
basic.forever(() => { basic.forever(() => {
basic.showLeds(` basic.showLeds(`
. # . # . . # . # .
# # # # # # # # # #
# # # # # # # # # #
. # # # . . # # # .
. . # . .`); . . # . .`
);
basic.pause(500); basic.pause(500);
basic.clearScreen(); basic.clearScreen();
basic.pause(500); basic.pause(500);
@ -94,20 +98,22 @@ Add a second image of a broken heart.
```blocks ```blocks
basic.forever(() => { basic.forever(() => {
basic.showLeds(` basic.showLeds(`
. # . # . . # . # .
# # # # # # # # # #
# # # # # # # # # #
. # # # . . # # # .
. . # . .`); . . # . .`
);
basic.pause(500); basic.pause(500);
basic.clearScreen(); basic.clearScreen();
basic.pause(500); basic.pause(500);
basic.showLeds(` basic.showLeds(`
. # . # . . # . # .
# . # # # # . # # #
# . . . # # . . . #
. # # # . . # # # .
. . # . .`); . . # . .`
);
basic.pause(500); basic.pause(500);
basic.clearScreen(); basic.clearScreen();
basic.pause(500); basic.pause(500);

View File

@ -24,6 +24,12 @@ Build your own music player micro:bit from headphones.
* [Connect your headphone](/projects/hack-your-headphone/making) * [Connect your headphone](/projects/hack-your-headphone/making)
* [Play sounds!]() * [Play sounds!]()
# ~hint
**No crocodile clips!?!?!** Use wires or Aluminium foil! [Read more...](/device/foil-circuits)
# ~
### ~button /projects/hack-your-headphones/making ### ~button /projects/hack-your-headphones/making
Let's get started! Let's get started!

View File

@ -6,6 +6,12 @@ Did you know you could attach your headhpones to the micro:bit to generate sound
### ~ ### ~
# ~hint
**No crocodile clips!?!?!** Use wires or Aluminium foil! [Read more...](/device/foil-circuits)
# ~
### Step 1 ### Step 1
![](/static/mb/lessons/banana-keyboard-1.png) ![](/static/mb/lessons/banana-keyboard-1.png)

View File

@ -10,11 +10,12 @@ Use [show leds](/reference/basic/show-leds) to make a smiley face:
```blocks ```blocks
basic.showLeds(` basic.showLeds(`
. # . # . . # . # .
. # . # . . # . # .
. . . . . . . . . .
# . . . # # . . . #
. # # # .`); . # # # .`
);
``` ```
## Step 2 ## Step 2
@ -24,18 +25,20 @@ frowny face inside it:
```blocks ```blocks
basic.showLeds(` basic.showLeds(`
. # . # .
. # . # .
. . . . .
# . . . #
. # # # .`);
input.onButtonPressed(Button.A, () => {
basic.showLeds(`
. # . # . . # . # .
. # . # . . # . # .
. . . . . . . . . .
. # # # . # . . . #
# . . . #`); . # # # .`
);
input.onButtonPressed(Button.A, () => {
basic.showLeds(`
. # . # .
. # . # .
. . . . .
. # # # .
# . . . #`
);
}); });
``` ```
@ -45,25 +48,28 @@ Now add blocks so that when [button B is pressed](/reference/input/button-is-pre
```blocks ```blocks
basic.showLeds(` basic.showLeds(`
. # . # .
. # . # .
. . . . .
# . . . #
. # # # .`);
input.onButtonPressed(Button.A, () => {
basic.showLeds(`
. # . # .
. # . # .
. . . . .
. # # # .
# . . . #`);
});
input.onButtonPressed(Button.B, () => {
basic.showLeds(`
. # . # . . # . # .
. # . # . . # . # .
. . . . . . . . . .
# . . . # # . . . #
. # # # .`); . # # # .`
);
input.onButtonPressed(Button.A, () => {
basic.showLeds(`
. # . # .
. # . # .
. . . . .
. # # # .
# . . . #`
);
});
input.onButtonPressed(Button.B, () => {
basic.showLeds(`
. # . # .
. # . # .
. . . . .
# . . . #
. # # # .`
);
}); });
``` ```

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -0,0 +1,80 @@
{
"Math.randomBoolean|block": "pick random true or false",
"Math|block": "Math",
"String.fromCharCode|block": "text from char code %code",
"String|block": "String",
"basic.clearScreen|block": "clear screen",
"basic.forever|block": "forever",
"basic.pause|block": "pause (ms) %pause",
"basic.showLeds|block": "show leds",
"basic.showNumber|block": "show|number %number",
"basic.showString|block": "show|string %text",
"basic|block": "basic",
"control.inBackground|block": "run in background",
"control.reset|block": "reset",
"control.waitMicros|block": "wait (µs)%micros",
"control|block": "control",
"game.addScore|block": "change score by|%points",
"game.gameOver|block": "game over",
"game.score|block": "score",
"game.startCountdown|block": "start countdown|(ms) %duration",
"game|block": "game",
"images.createBigImage|block": "create big image",
"images.createImage|block": "create image",
"images|block": "images",
"input.acceleration|block": "acceleration (mg)|%NAME",
"input.buttonIsPressed|block": "button|%NAME|is pressed",
"input.compassHeading|block": "compass heading (°)",
"input.lightLevel|block": "light level",
"input.magneticForce|block": "magnetic force (µT)|%NAME",
"input.onButtonPressed|block": "on button|%NAME|pressed",
"input.onGesture|block": "on |%NAME",
"input.onPinPressed|block": "on pin %NAME|pressed",
"input.onPinReleased|block": "on pin %NAME|released",
"input.pinIsPressed|block": "pin %NAME|is pressed",
"input.rotation|block": "rotation (°)|%NAME",
"input.runningTime|block": "running time (ms)",
"input.setAccelerometerRange|block": "set accelerometer|range %range",
"input.temperature|block": "temperature (°C)",
"input|block": "input",
"led.brightness|block": "brightness",
"led.plotBarGraph|block": "plot bar graph of %value |up to %high",
"led.plot|block": "plot|x %x|y %y",
"led.point|block": "point|x %x|y %y",
"led.setBrightness|block": "set brightness %value",
"led.stopAnimation|block": "stop animation",
"led.toggle|block": "toggle|x %x|y %y",
"led.unplot|block": "unplot|x %x|y %y",
"led|block": "led",
"music.beat|block": "%fraction|beat",
"music.changeTempoBy|block": "change tempo by (bpm)|%value",
"music.noteFrequency|block": "%note",
"music.playTone|block": "play|tone %note=device_note|for %duration=device_beat",
"music.rest|block": "rest(ms)|%duration=device_beat",
"music.ringTone|block": "ring tone (Hz)|%note=device_note",
"music.setTempo|block": "set tempo to (bpm)|%value",
"music.tempo|block": "tempo (bpm)",
"music|block": "music",
"pins.analogReadPin|block": "analog read|pin %name",
"pins.analogSetPeriod|block": "analog set period|pin %pin|to (µs)%micros",
"pins.analogWritePin|block": "analog write|pin %name|to %value",
"pins.digitalReadPin|block": "digital read|pin %name",
"pins.digitalWritePin|block": "digital write|pin %name|to %value",
"pins.i2cReadNumber|block": "i2c read number|at address %address|of format %format=i2c_sizeof",
"pins.i2cWriteNumber|block": "i2c write number|at address %address|with value %value|of format %format=i2c_sizeof",
"pins.map|block": "map %value|from low %fromLow|from high %fromHigh|to low %toLow|to high %toHigh",
"pins.onPulsed|block": "on|pin %pin|pulsed %pulse",
"pins.pulseDuration|block": "pulse duration (µs)",
"pins.servoSetPulse|block": "servo set pulse|pin %value|to (µs) %micros",
"pins.servoWritePin|block": "servo write|pin %name|to %value",
"pins.setPull|block": "set pull|pin %pin|to %pull",
"pins.spiWrite|block": "spi write %value",
"pins|block": "pins",
"serial.readLine|block": "serial read line",
"serial.redirect|block": "serial redirect to|TX %tx|RX %rx|at baud rate %rate",
"serial.writeLine|block": "serial|write line %text",
"serial.writeNumber|block": "serial|write number %value",
"serial.writeString|block": "serial write string %text",
"serial.writeValue|block": "serial|write value %name|= %value",
"serial|block": "serial"
}

View File

@ -33,7 +33,9 @@
"parts/speaker.svg", "parts/speaker.svg",
"parts/headphone.svg", "parts/headphone.svg",
"parts/dcmotor.svg", "parts/dcmotor.svg",
"_locales/fr/microbit-jsdoc-strings.json" "_locales/ja/core-jsdoc-strings.json",
"_locales/ja/core-strings.json",
"_locales/fr/core-jsdoc-strings.json"
], ],
"public": true, "public": true,
"dependencies": {}, "dependencies": {},