Compare commits
230 Commits
Author | SHA1 | Date | |
---|---|---|---|
9c96591edd | |||
4f38658d74 | |||
6329a79ce1 | |||
befbdd32cc | |||
44688ee5d5 | |||
cc36bae97d | |||
c65bdb34af | |||
21f7ef9b55 | |||
d7250d54f8 | |||
9a36a2fc05 | |||
539357237f | |||
35d59da17e | |||
0b226bc9aa | |||
f2bab5d122 | |||
6e6a98559c | |||
217fce953d | |||
bfac2910da | |||
5962c28b0e | |||
d3509a6254 | |||
df91bf234c | |||
2a46935f62 | |||
5e024c6f23 | |||
28b3d823b2 | |||
b7c9bc7978 | |||
52b2ee3f4c | |||
263cc25633 | |||
2e3d875b7d | |||
7704ad9f8d | |||
845d7a004c | |||
1cf070d649 | |||
24420a2cc4 | |||
2f8b61998b | |||
af38071c6a | |||
89f09c7f35 | |||
a667467bbd | |||
ada2583e17 | |||
c04538313d | |||
1039dc560e | |||
957c7ad848 | |||
5e7351a481 | |||
f0c089373b | |||
879a85bdbb | |||
7a9c2e0fe4 | |||
9656c1159a | |||
801117d6b0 | |||
c084bff334 | |||
18bf35f179 | |||
7e7dc91947 | |||
da79f643dc | |||
ea10cde3eb | |||
0a60b0ee37 | |||
b4bc985068 | |||
78f9af5bc2 | |||
e9410d17a6 | |||
ca8ef260d5 | |||
5ea5e9bb5b | |||
19c689a8c4 | |||
72226cd4e5 | |||
0d3af60892 | |||
f88cda8244 | |||
f71925fdd2 | |||
bfeda371a9 | |||
eb09530391 | |||
346d1e77da | |||
bf384355c4 | |||
3801e52370 | |||
99574f1ec8 | |||
12705eed06 | |||
a62f2b00b4 | |||
7d0101af25 | |||
60c3f1f427 | |||
8552a2de52 | |||
b0d4fdb009 | |||
d3294ee99e | |||
00d23f8437 | |||
1c6c749dad | |||
2803c00814 | |||
f150d93070 | |||
7f284b2a57 | |||
0e5c30ec7c | |||
2cc6f864a8 | |||
d428a2cd1f | |||
47f9362e5f | |||
38b197bc03 | |||
9a404854e7 | |||
d17a8de72d | |||
9d1f2e024b | |||
e7d8559fe3 | |||
fcfdbcc7e4 | |||
5884231399 | |||
e8887f5904 | |||
07e8610e5d | |||
37fb907f04 | |||
13f42f5892 | |||
5fcf9165ea | |||
b33d0ba470 | |||
b9f66c5c6b | |||
9848409283 | |||
ce16e64660 | |||
4d056e0c23 | |||
70b2827cf0 | |||
62e4b04931 | |||
17e33cc34f | |||
d4ad150cba | |||
52bfd4e535 | |||
f854dfd9c8 | |||
d905f24f9c | |||
81b8b1b69c | |||
efce4c3698 | |||
b5e4a36e9c | |||
04a60a5b47 | |||
29b28e7f0d | |||
979381eaef | |||
e4370f4e3c | |||
ba707f080d | |||
3816e01f87 | |||
548d215b48 | |||
43da58f214 | |||
f90d052538 | |||
13ff7cd0ec | |||
a3b34518b0 | |||
5a33dc8a81 | |||
7349e28898 | |||
26b9fdf40e | |||
3cf82b9be2 | |||
546c44bafa | |||
d727d3fcde | |||
6b0cf961c6 | |||
18419d763d | |||
99fdb53fa0 | |||
879fdd687e | |||
6c1b879c34 | |||
019bbc79fc | |||
f857a88541 | |||
6531e7bfbb | |||
2147225afd | |||
841ea6d060 | |||
3dddb2eb30 | |||
651cf14556 | |||
7f6fb5559b | |||
ea724038dc | |||
19757d4245 | |||
07a7b4048a | |||
45742aa2ac | |||
db0c5d9f9f | |||
8285250a1b | |||
de0257c7e9 | |||
3580012065 | |||
cdb23fffb6 | |||
6937c51549 | |||
69e90523e2 | |||
f76235736a | |||
8431243b63 | |||
458b4553d2 | |||
0f6e8854d8 | |||
5565bb7d24 | |||
6c539fb04f | |||
b30a0ced87 | |||
ac942e198a | |||
cef1f57e30 | |||
980ad6ce91 | |||
53bfea5752 | |||
4917bb7e39 | |||
139823203e | |||
883f4d1a20 | |||
0bce69edd0 | |||
efccc921cb | |||
55859b1237 | |||
ec09d40366 | |||
512e40fae3 | |||
028dac25f6 | |||
e0d4763974 | |||
3b3e402ffa | |||
e37ac1a1d7 | |||
17eb36a8dc | |||
10d44b97cc | |||
505c750dd0 | |||
d0e900606a | |||
dcbb076266 | |||
22c852f2d9 | |||
76770bc0e1 | |||
572080bc6d | |||
0b8142ae73 | |||
09a06d9fa9 | |||
80e8c6684d | |||
4cccb36f3d | |||
a427a1e720 | |||
be77c5296b | |||
a0c1b2c580 | |||
fc905c5f8f | |||
f1bd84733b | |||
d3080d2e66 | |||
090e530ff0 | |||
094e9d25cd | |||
0bcb9c16fa | |||
269bdb82a6 | |||
cba7e02bcd | |||
8ef834b73b | |||
ec54622f52 | |||
5d90b70425 | |||
8cef13e517 | |||
82986c091b | |||
67f2fdcfec | |||
d11c5a9028 | |||
b7cb7e477e | |||
0d1059aedf | |||
b92fc783fa | |||
6d73e5e129 | |||
6150850729 | |||
76a18fa61b | |||
2bd66ae4ef | |||
f6eefde27c | |||
60c9e4a82f | |||
56713227c5 | |||
fd6e110790 | |||
2336521df1 | |||
2ce72aeb28 | |||
e746c13212 | |||
9e073aee36 | |||
3906f06a2f | |||
d89747fa46 | |||
c4e6618baa | |||
5232be58ce | |||
5a75483811 | |||
4b40585690 | |||
dd65efaab6 | |||
890c2566af | |||
cd71fc5d13 | |||
f626dd4bbb | |||
956992e9ab |
@ -13,4 +13,5 @@ notifications:
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
- built/cache
|
||||
|
||||
|
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
// Place your settings in this file to overwrite default and user settings.
|
||||
{
|
||||
"tslint.enable": true,
|
||||
"tslint.rulesDirectory": "node_modules/tslint-microsoft-contrib"
|
||||
}
|
40
README.md
@ -3,24 +3,44 @@
|
||||
This target allow to program a [BBC micro:bit](https://www.microbit.co.uk/) using
|
||||
[Microsoft Programming Experience Toolkit](https://github.com/Microsoft/pxt).
|
||||
|
||||
* [Try it live](https://m.pxt.io)
|
||||
|
||||
[](https://travis-ci.org/Microsoft/pxt-microbit)
|
||||
|
||||
# Getting started
|
||||
## Local server
|
||||
|
||||
Please follow instructions at https://github.com/Microsoft/pxt#running-a-target-from-localhost
|
||||
### Setup
|
||||
|
||||
The following commands are a 1-time setup after synching the repo on your machine.
|
||||
|
||||
* install the PXT command line
|
||||
```
|
||||
npm install -g pxt
|
||||
```
|
||||
* install the dependencies
|
||||
```
|
||||
npm install
|
||||
```
|
||||
|
||||
### Running
|
||||
|
||||
Run this command to open a local web server:
|
||||
```
|
||||
pxt serve
|
||||
```
|
||||
To make sure you're running the latest tools, run
|
||||
```
|
||||
npm update
|
||||
```
|
||||
|
||||
More instructions at https://github.com/Microsoft/pxt#running-a-target-from-localhost
|
||||
|
||||
## Universal Windows App
|
||||
|
||||
The Windows 10 app is a [Universal Windows Hosted Web App](https://microsoftedge.github.io/WebAppsDocs/en-US/win10/CreateHWA.htm)
|
||||
that wraps codemicrobit.com and provides additional features.
|
||||
|
||||
### Sideloading
|
||||
|
||||
* Open Windows **settings** and search for **Developer options**
|
||||
* Enable the developer mode.
|
||||
* Find the latest build under ``win10/app/AppPackages/latest`` and run the ``Add-AppDevPackage.ps1`` PowerShell script (mouse right-click, then `run with PowerShell`)
|
||||
that wraps m.pxt.io and provides additional features.
|
||||
|
||||
### Building
|
||||
|
||||
* Install Visual Studio 2015 Update 2 or higher. Make sure the Windows 10 templates are installed.
|
||||
* open the ``win10/app.sln`` solution and launch the ``codemicrobit`` project.
|
||||
* open the ``win10/app.sln`` solution and launch the ``m.pxt.io`` project.
|
||||
|
22
docs/_locales/pl/_theme.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "koduj z micro:bit",
|
||||
"title": "koduj z micro:bit",
|
||||
"docMenu": [
|
||||
{
|
||||
"name": "O nas",
|
||||
"path": "/about"
|
||||
},
|
||||
{
|
||||
"name": "Lekcje",
|
||||
"path": "/lessons"
|
||||
},
|
||||
{
|
||||
"name": "Instrukcja obsługi",
|
||||
"path": "/reference"
|
||||
},
|
||||
{
|
||||
"name": "Urządzenie",
|
||||
"path": "/device"
|
||||
}
|
||||
]
|
||||
}
|
7
docs/_locales/pl/docs.md
Normal file
@ -0,0 +1,7 @@
|
||||
# Dokumentacja
|
||||
|
||||
Witamy na stronach dokumentacji!
|
||||
|
||||
* Przeglądnij [instrukcje obsługi](/reference)
|
||||
* Dowiedz się więcej o [urządzeniu](/device)
|
||||
* Wystartuj z [lekcjami](/lessons)
|
@ -26,7 +26,7 @@ input.onButtonPressed(Button.B, () => {
|
||||
The [BBC micro:bit](https://www.microbit.co.uk) is a [pocket-size computer](/device) with a 5x5 display of 25 LEDs, Bluetooth and sensors that can be programmed by anyone.
|
||||
The BBC micro:bit was made possible by many [partners](https://www.microbit.co.uk/partners).
|
||||
|
||||
The micro:bit provides a fun introduction to programming and making – switch on, program it to do something fun – wear it, customize it.
|
||||
The micro:bit provides an easy and fun introduction to programming and making – switch on, program it to do something fun – wear it, customize it.
|
||||
Just like Arduino, the micro:bit can be connected to and interact with sensors, displays, and other devices.
|
||||
|
||||
## Blocks or JavaScript
|
||||
|
@ -11,9 +11,7 @@ This example displays a random number every time the crocodile clip holds `GND`
|
||||
|
||||
### Connecting Crocodile Clips
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
### Lessons
|
||||
|
||||
|
32
docs/docs.md
@ -1,7 +1,35 @@
|
||||
# Documentation
|
||||
|
||||
Welcome to the documentation.
|
||||
```sim
|
||||
basic.forever(() => {
|
||||
basic.showString("DOCS ");
|
||||
})
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
led.stopAnimation();
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .`);
|
||||
});
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
led.stopAnimation();
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# . # . #
|
||||
# . . . #
|
||||
. # . # .
|
||||
. . # . .`);
|
||||
});
|
||||
```
|
||||
|
||||
* Browse the [reference](/reference)
|
||||
* **[getting started](/getting-started)**
|
||||
* Browse the [API reference](/reference)
|
||||
* Learn more about the [device](/device)
|
||||
* Get started with [lessons](/lessons)
|
||||
* Follow up with the [release notes](/release-notes)
|
||||
|
||||
### Developers
|
||||
|
||||
* Learn about [packages](/packages) (possibly using C++ or ARM thumb)
|
||||
|
171
docs/getting-started.md
Normal file
@ -0,0 +1,171 @@
|
||||
# Getting started
|
||||
|
||||
Are you ready to build cool BBC micro:bit programs? For each challenge, reorder the blocks to recreate the program.
|
||||
|
||||
## Open [https://m.pxt.io](/) and create a new **Blocks Editor** project
|
||||
|
||||
## Basic
|
||||
|
||||
### Show leds
|
||||
|
||||
Use the blocks below to draw a figure on the screen. You can redo the smiley face or try something else!
|
||||
|
||||
```shuffle
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
```
|
||||
|
||||
To transfer your code to the BBC micro:bit,
|
||||
* connect your micro:bit to the computer using the USB cable
|
||||
* click on **Download**
|
||||
* drag&drop the **.hex** file into the **MICROBIT** drive
|
||||
* wait till the yellow light is done blinking!
|
||||
|
||||
### Show animation Forever
|
||||
|
||||
Show one image after the other to create an animation by snapping them together.
|
||||
|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # # # .
|
||||
# . . . #
|
||||
`)
|
||||
```
|
||||
|
||||
|
||||
### Repeat forever
|
||||
|
||||
Use the ``forever`` block to repeat your code and have a continuous animation.
|
||||
|
||||
Unsuffle the blocks to create a happy, unhappy animation.... or changes the image to make it your own!
|
||||
```shuffle
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # # # .
|
||||
# . . . #
|
||||
`)
|
||||
});
|
||||
```
|
||||
|
||||
### Your turn now!
|
||||
|
||||
Use the blocks ``show leds`` and ``forever``
|
||||
to create your own custom awesome animation!
|
||||
|
||||
## Inputs
|
||||
|
||||
### Button A and B
|
||||
|
||||
Unshuffle the blocks so that the micro:bit shows "YES" when button A is pressed, and "NO" when B is pressed.
|
||||
The key idea is that all the blocks nested under `on button ... pressed` will run when that button is pressed.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showString("AAAAA");
|
||||
});
|
||||
```
|
||||
|
||||
Try to unshuffle those blocks:
|
||||
```shuffle
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showString("YES");
|
||||
});
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
basic.showString("NO");
|
||||
});
|
||||
```
|
||||
|
||||
### Shake
|
||||
|
||||
Using the data from the **accelerometer**, it is possible to detect that the BBC micro:bit is being shaken.
|
||||
|
||||
Unshuffle the code to display a frownie when shaken.
|
||||
```shuffle
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # # # .
|
||||
# . . . #`);
|
||||
});
|
||||
```
|
||||
|
||||
### Tilting
|
||||
|
||||
Aside from shake, it is also possible to detect tilt left and right, logo up and down or face up and down.
|
||||
Let's build a rock paper scissors game where you turn the micro:bit left to display paper, right to display scissors and down to display rock.
|
||||
|
||||
Unshuffle and try this code on the micro:bit itself!
|
||||
```shuffle
|
||||
input.onGesture(Gesture.TiltLeft, () => {
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# . . . #
|
||||
# . . . #
|
||||
# . . . #
|
||||
# # # # #`);
|
||||
});
|
||||
input.onGesture(Gesture.LogoDown, () => {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # # # .
|
||||
. # # # .
|
||||
. # # # .
|
||||
. . . . .`);
|
||||
});
|
||||
input.onGesture(Gesture.TiltRight, () => {
|
||||
basic.showLeds(`
|
||||
# # . . #
|
||||
# # . # .
|
||||
. . # . .
|
||||
# # . # .
|
||||
# # . . #`);
|
||||
});
|
||||
```
|
||||
|
||||
### Pins
|
||||
|
||||
It is possible to use the pins (big metal bar at the bottom of the board) as button. Hold the ``GND`` button with one hand and press the ``0`` pin
|
||||
(called ``P0``) with the other hand to trigger a pin pressed.
|
||||
|
||||
Unshuffle the blocks to display a smiley when pin ``P0`` is pressed.
|
||||
```shuffle
|
||||
input.onPinPressed(TouchPin.P0, () => {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .`);
|
||||
});
|
||||
```
|
||||
|
||||
### Your turn now!
|
||||
|
||||
Use the scree, buttons, gestures, pins to create a fun game using the micro:bit.
|
@ -57,8 +57,10 @@
|
||||
* [Telegraph](/lessons/telegraph), play the telegraph game between two BBC micro:bits
|
||||
* [Pogo](/lessons/pogo), create a pogo game to test your jumping abilities
|
||||
|
||||
## Science
|
||||
* [Charting](/lessons/charting), measure and chart acceleration
|
||||
|
||||
## Advanced
|
||||
* [Charting](/lessons/charting), create a charting app between 2 BBC micro:bits
|
||||
* [Prank WiFi](/lessons/prank-wifi), create fake WiFi to trick your friends
|
||||
* [Speed Button](/lessons/speed-button), code a speed game with running time
|
||||
* [Headbands](/lessons/headbands), create a charades game with a collection of strings that hold the words
|
||||
@ -68,5 +70,4 @@
|
||||
|
||||
### @section full
|
||||
|
||||
The lessons promote computational thinking and computer science literacy[ read more...](/lessons/teach)
|
||||
|
||||
The lessons promote computational thinking and computer science literacy[ read more...](/lessons/teach)
|
@ -21,7 +21,6 @@ basic.showString("ASK ME A QUESTION")
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showString("Yes")
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
* `Run` the code to see if it works as expected.
|
||||
@ -45,7 +44,6 @@ input.onButtonPressed(Button.B, () => {
|
||||
|
||||
* `Run` the code to see if it works as expected.
|
||||
|
||||
**Challenge 3**
|
||||
|
||||
When you are asked a yes or no question, do you always say yes or no? Add a condition for `on shake` that displays `MAYBE`.
|
||||
### Challenge 3
|
||||
|
||||
When you are asked a yes or no question, do you always say yes or no? Add a condition for `on shake` that displays `MAYBE`.
|
@ -12,7 +12,6 @@ Answers may vary. This is a function that will show a string on the LED screen o
|
||||
|
||||
```blocks
|
||||
basic.showString("Y")
|
||||
|
||||
```
|
||||
|
||||

|
||||
@ -22,7 +21,6 @@ basic.showString("Y")
|
||||
|
||||
```blocks
|
||||
basic.showString("Hi")
|
||||
|
||||
```
|
||||
|
||||

|
||||
@ -35,7 +33,6 @@ basic.showString("Hi")
|
||||
|
||||
```blocks
|
||||
basic.showString("Z")
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
@ -39,9 +39,9 @@ basic.showLeds(`
|
||||
`)
|
||||
```
|
||||
|
||||
* *Run* your code to see if it works as expected.
|
||||
* Does your code work as expected?
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Nice job! Why don't we create a third image that will show after the other two? Remember to add a pause before you create and show the image.
|
||||
Nice job! Why don't we create a third image that will show after the other two?
|
||||
|
||||
|
@ -12,17 +12,14 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
|
||||
|
||||
## 1. Write the code that will store the global variable named 'action' and returns a random number between 0 and 2
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
action = Math.random(3)
|
||||
```blocks
|
||||
let action = Math.random(3)
|
||||
```
|
||||
|
||||
## 2. Write the code that will display the string, "PUSH A" if the global variable called 'action' is equal to 0
|
||||
|
||||
<br />
|
||||
|
||||
```
|
||||
```blocks
|
||||
let action = Math.random(3)
|
||||
if (action == 0) {
|
||||
basic.showString("PUSH A", 150)
|
||||
}
|
||||
@ -30,10 +27,9 @@ if (action == 0) {
|
||||
|
||||
## 3. Write the code that increments the score if button A is pressed when the global variable called 'action' is equal to 1
|
||||
|
||||
<br />
|
||||
|
||||
```
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
let action = Math.random(3)
|
||||
if (action == 0) {
|
||||
game.addScore(1)
|
||||
}
|
||||
@ -42,9 +38,8 @@ input.onButtonPressed(Button.A, () => {
|
||||
|
||||
## 4. Write the code that will display the string "LOGO DOWN" if the global variable called 'action' is equal to 1
|
||||
|
||||
<br />
|
||||
|
||||
```
|
||||
```blocks
|
||||
let action = Math.random(3)
|
||||
if (action == 1) {
|
||||
basic.showString("LOGO DOWN", 150)
|
||||
}
|
||||
@ -52,10 +47,9 @@ if (action == 1) {
|
||||
|
||||
## 5. Write the code that increments the score if the BBC micro:bit logo is tilted down when the global variable called 'action' is equal to 1
|
||||
|
||||
<br />
|
||||
|
||||
```
|
||||
```blocks
|
||||
input.onLogoDown(() => {
|
||||
let action = Math.random(3)
|
||||
if (action == 1) {
|
||||
game.addScore(1)
|
||||
}
|
||||
@ -64,9 +58,8 @@ input.onLogoDown(() => {
|
||||
|
||||
## 6. Write the code that will display the string "SHAKE" if the global variable called 'action' is equal to 2
|
||||
|
||||
<br />
|
||||
|
||||
```
|
||||
```blocks
|
||||
let action = Math.random(3)
|
||||
if (action == 2) {
|
||||
basic.showString("SHAKE", 150)
|
||||
}
|
||||
@ -74,13 +67,11 @@ if (action == 2) {
|
||||
|
||||
## 7. Write the code that increments the score if the BBC micro:bit is shaken when the global variable called 'action' is equal to 2
|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
```blocks
|
||||
input.onLogoDown(() => {
|
||||
let action = Math.random(3)
|
||||
if (action == 1) {
|
||||
game.addScore(1)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
|
@ -11,6 +11,7 @@ Variables
|
||||
## Quick Links
|
||||
|
||||
* [activity](/lessons/catch-the-egg-game/activity)
|
||||
* [tutorial](/lessons/catch-the-egg-game/tutorial)
|
||||
* [quiz](/lessons/catch-the-egg-game/quiz)
|
||||
* [quiz answers](/lessons/catch-the-egg-game/quiz-answers)
|
||||
|
||||
@ -20,18 +21,21 @@ Learn how to create a catch the egg game game with **plot**, `led->plot` , **unp
|
||||
|
||||
## Documentation
|
||||
|
||||
* **variables** : [read more...](/reference/variables/var)
|
||||
* **forever** : [read more...](/reference/basic/forever)
|
||||
* **unplot** : [read more...](/reference/led/unplot)
|
||||
* **plot** : [read more...](/reference/led/plot)
|
||||
* **if** : [read more...](/reference/logic/if)
|
||||
* **acceleration** : [read more...](/reference/input/acceleration)
|
||||
* **math minimum number** : [read more...](/reference/math)
|
||||
* **math maximum number** : [read more...](/reference/math)
|
||||
* **math random number** : [read more...](/reference/math)
|
||||
* **math modulus** : [read more...](/reference/math)
|
||||
* **show number** : [read more...](/reference/basic/show-number)
|
||||
* **pause** : [read more...](/reference/basic/pause)
|
||||
```cards
|
||||
let x = 2;
|
||||
led.unplot(0, 0);
|
||||
basic.forever(() => {});
|
||||
x += 1;
|
||||
led.plot(0, 0);
|
||||
basic.pause(300);
|
||||
input.acceleration(Dimension.X);
|
||||
Math.min(0,0);
|
||||
Math.max(0,1);
|
||||
Math.random(5);
|
||||
game.addScore(1);
|
||||
game.score();
|
||||
game.removeLife(1);
|
||||
```
|
||||
|
||||
## Objectives
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
# catch the egg game challenges
|
||||
|
||||
Coding challenges for catch the egg game.
|
||||
|
||||
## Before we get started
|
||||
|
||||
Your starting code should look like this:
|
||||
|
29
docs/lessons/catch-the-egg-game/tutorial.md
Normal file
@ -0,0 +1,29 @@
|
||||
# catch the egg game tutorial
|
||||
|
||||
### Rebuild the game!
|
||||
|
||||
The blocks have been shuffled! Put them back together so that...
|
||||
* an egg LED falls from the top of the screen, row by row.
|
||||
* a basket LED is on the bottom row and can be moved by using the accelerometer `X` data.
|
||||
* if the egg LED reaches the last row, reset the egg position to the first row.
|
||||
|
||||
```shuffle
|
||||
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)
|
||||
})
|
||||
```
|
@ -1,15 +1,16 @@
|
||||
# charting lesson
|
||||
|
||||
Measure the acceleration on the micro:bit in the "z" direction.
|
||||
Create a charting app for simulating and measuring the acceleration applied to the micro:bit
|
||||
|
||||
## Topic
|
||||
|
||||
Acceleration
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [activity](/lessons/charting/activity)
|
||||
|
||||
* [activity](/lessons/charting/acceleration)
|
||||
* [challenge](/lessons/charting/challenge)
|
||||
* [quiz](/lessons/charting/quiz)
|
||||
* [answers](/lessons/charting/quiz-answers)
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
@ -18,9 +19,9 @@ Learn the functions of **on data received**, **send number** and **receive numbe
|
||||
## Documentation
|
||||
|
||||
```cards
|
||||
basic.showNumber(0)
|
||||
input.acceleration(Dimension.X)
|
||||
led.plotBarGraph(0, 1023)
|
||||
basic.showNumber(0)
|
||||
radio.onDataReceived(() => {})
|
||||
radio.sendNumber(0)
|
||||
radio.receiveNumber()
|
||||
|
@ -1,53 +1,85 @@
|
||||
# charting activity
|
||||
# Activity
|
||||
|
||||
Measure the acceleration on the micro:bit in the "z" direction.
|
||||
Measure the acceleration on the micro:bit in the "x" direction.
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Welcome! This activity will teach how to use the micro:bit to chart the acceleration in the "x" direction. Let's get started!
|
||||
|
||||
|
||||
### ~
|
||||
Let's measure `acceleration (mg)` in the "x" direction. Get the acceleration value (milli g-force), in one of three specified dimensions.
|
||||
|
||||
|
||||
```blocks
|
||||
input.acceleration(Dimension.X)
|
||||
|
||||
```
|
||||
|
||||
### ~
|
||||
Use the plot bar chart to visualize the acceleration on the LED screen of the micro:bit in the specified range. You implement plot Bar Graph to display a vertical bar graph based on the "value" and "high" value. Then you must insert acceleration in the X dimension to measure the acceleration.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
led.plotBarGraph(input.acceleration(Dimension.X), 0)
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
### ~
|
||||
Notice that moving the micro:bit in the simulator from left to right (x direction) changes the values beneath the micro:bit in a range from 1023 to -1023 as measured in milli-gravities. By hovering over the micro:bit from left to right, you can observe changing values beneath the micro:bit simulator. Also, the LEDs shown on the Bar Graph fluctates based on the movement of the micro:bit simulator in the x direction. The line underneath the micro:bit simulator reflect the acceleration in the x direction.
|
||||
|
||||
NOTE: The colors of the charts reflect the color of the micro:bit simulator. In this instance, the micro:bit is yellow. So the color of the data line reflects the color of the micro:bit
|
||||
|
||||

|
||||
|
||||
### ~
|
||||
|
||||
Vigorously move the micro:bit in the micro:bit simulatator by moving the micro:bit image from side to side. Every time the micro:bit moves in the x direction in the simulator, you are generating data points that can be reviewed in Excel. The more attempts to move the micro:bit from side to side, the more data being saved in Excel. After you have vigarously moved the micro:bit simulator from side to side for a sufficient amount of time, you are ready to graph or chart the accceleration of the micro:bit. We want a printout of our acceleration on Excel that can be graphed in Excel.
|
||||
|
||||
### ~
|
||||
|
||||
Welcome! This activity will teach how to use the 1st micro:bit to chart the second micro:bit's acceleration in the "x" direction. Let's get started!
|
||||
We want to chart the data collected by using a tool in Excel.
|
||||
|
||||
Let's measure `acceleration (mg)` and then `send number`. `Acceleration` is measured in **milli-gravities**, so a value of -1000 is equivalent to -1g or -9.81m/s^2. We will be able to get the acceleration value (g-force), in the specified "x" dimension. `Send number` will broadcast a number data packet to other micro:bits connected via radio.
|
||||
|
||||
```blocks
|
||||
radio.sendNumber(input.acceleration(Dimension.X));
|
||||
```
|
||||
|
||||
We want to display the acceleration forever. In order to do so, we need a `forever` loop. A forever loop will repeat code in the background forever.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
radio.sendNumber(input.acceleration(Dimension.X));
|
||||
});
|
||||
The final part of this experiment is opening and reviewing the data in the Excel CSV file. Simply click on the line beneath the simulator. A CSV file will be generated to display the data points collected by moving the micro:bit in the X direction. Then click or tap on the data Excel file that was downloaded to your local Downloads Folder.
|
||||
|
||||
|
||||
```
|
||||
|
||||
We want to register code to run when a packet is received over radio. We can implement this code by adding `on data received`.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
radio.sendNumber(input.acceleration(Dimension.X))
|
||||
})
|
||||
radio.onDataReceived(() => {
|
||||
|
||||
})
|
||||
```
|
||||
|
||||
Finally, we want to chart the acceleration. So we must first implement `plot bar graph`. `Plot Bar Graph` will display a vertical bar graph based on the value and high value. In order to transfer the receive the number from the 1st micro:bit, we must implement `receive number` to constantly display a vertical bar graph based on the value. Remember, the value will equal to the micro:bit's acceleration in the "x" direction.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
radio.sendNumber(input.acceleration(Dimension.X))
|
||||
})
|
||||
radio.onDataReceived(() => {
|
||||
led.plotBarGraph(radio.receiveNumber(), 1023)
|
||||
})
|
||||
|
||||
```
|
||||
### ~
|
||||
|
||||
|
||||
* Connect the first micro:bit to your computer using your USB cable and run the charting script on it.
|
||||
* Connect the second micro:bit to your computer using your USB cable and run the charting script on it.
|
||||
* The first person and second person take turns tilting the micro:bit in the "x" direction while the other player charts the data on the micro:bit!
|
||||
First, click or tap on the first two columns (A, B) to include the time of the data being collected; b) the results of acceleration data on the micro:bit
|
||||
|
||||

|
||||
|
||||
Use the Recommended Charts command on the Insert tab to quickly create a chart that’s just right for your data.
|
||||
|
||||
* Select the data that you want to include in your chart.
|
||||
|
||||
* Click Insert > Recommended Charts.
|
||||
|
||||

|
||||
|
||||
* On the Recommended Charts tab, scroll through the list of chart types that Excel recommends for your data.
|
||||
|
||||
Click any chart type to see how your data will look in that format.
|
||||
|
||||
When you find the chart type that you want, click it, and then click OK. We want to select the chart called Line. A line chart is used to display trends over time. We will use the line chart because there are many data points over time.
|
||||
|
||||
Tip: If you don’t see a chart type that you want, click the All Charts tab to see all of the available chart types.
|
||||
|
||||

|
||||
|
||||
* Use the Chart Elements, Chart Styles, and Chart Filters buttons next to the upper-right corner of the chart to add chart elements like axis titles or data labels, to customize the look of your chart
|
||||
|
||||

|
||||
|
||||
* Connect a micro:bit to your computer using your USB cable; compile; and repeat this experiment by moving the micro:bit in the "x" direction. Then collect and chart the data on Excel.
|
||||
* Review and analyze the actual micro:bit device data on Excel
|
||||
* Display acceleration with y or z using plot bar graph by changing acceleration from "x" to "y" or "z"
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/lessons/charting/acceleration-challenge)
|
||||
|
||||
### ~
|
||||
|
||||
|
94
docs/lessons/charting/challenge.md
Normal file
@ -0,0 +1,94 @@
|
||||
# Challenge
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Welcome! The activity will teach you how to use the acceleration of the 1st micro:bit and to visualize the acceleration on the 2nd micro:bit. Let's get started!
|
||||
|
||||
### ~
|
||||
Let's measure `acceleration (mg)` and then `send number`. `Acceleration` is measured in **milli-gravities**, so a value of -1000 is equivalent to -1g or -9.81m/s^2. We will be able to get the acceleration value (g-force), in the specified "x" dimension. `Send number` will broadcast a number data packet to other micro:bits connected via radio.
|
||||
|
||||
```blocks
|
||||
radio.sendNumber(input.acceleration(Dimension.X));
|
||||
```
|
||||
### ~
|
||||
We want to display the acceleration forever. In order to do so, we need a `forever` loop. A forever loop will repeat code in the background forever.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
radio.sendNumber(input.acceleration(Dimension.X));
|
||||
});
|
||||
|
||||
|
||||
```
|
||||
### ~
|
||||
We want to register code to run when a packet is received over radio. We can implement this code by adding `on data received`.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
radio.sendNumber(input.acceleration(Dimension.X))
|
||||
})
|
||||
radio.onDataReceived(() => {
|
||||
|
||||
})
|
||||
```
|
||||
### ~
|
||||
Finally, we want to chart the acceleration. So we must first implement `plot bar graph`. `Plot Bar Graph` will display a vertical bar graph based on the value and high value. In order to transfer the receive the number from the 1st micro:bit, we must implement `receive number` to constantly display a vertical bar graph based on the value. Remember, the value will equal to the micro:bit's acceleration in the "x" direction.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
radio.sendNumber(input.acceleration(Dimension.X))
|
||||
})
|
||||
radio.onDataReceived(() => {
|
||||
led.plotBarGraph(radio.receiveNumber(), 1023)
|
||||
})
|
||||
|
||||
```
|
||||
### ~
|
||||
Notice that moving the micro:bit the farthest direction in the x direction will be -1023 on the charting beneath the simulator. The second observation will be that the LEDs will be full brightness on the 2nd micro:bit. There is a single LED turned on with the 1st micro:bit. Additionally, the graphs will reflect 0 acceleation for the 1st micro:bit. In this scenario, if you are adjusting the acceleration in the simualator, you are also changing your chart that will be produced.
|
||||
|
||||

|
||||
|
||||
### ~
|
||||
NOTE: The colors of the charts reflect the color of the micro:bit simulator. In this instance, the micro:bits are blue and green. So the colors of the line graphs reflect the colors of the micro:bit
|
||||
|
||||
### ~
|
||||
After running this simulatation several seconds by moving the micro:bit side to side in the x direction, you are ready to graph or chart the accceleration of the micro:bit. We want a printout of our acceleration on Excel. We will graph the fluctuating acceleration of the simulation experiment.
|
||||
|
||||

|
||||
|
||||
### ~
|
||||
Finally, you must open the Excel CSV file by clicking on the data.xls file that was downloaded to Downloads Folder.
|
||||
|
||||

|
||||
|
||||
Use the Recommended Charts command on the Insert tab to quickly create a chart that’s just right for your data.
|
||||
|
||||
* Select the data that you want to include in your chart.
|
||||
|
||||
* Click Insert > Recommended Charts.
|
||||
|
||||

|
||||
|
||||
* On the Recommended Charts tab, scroll through the list of chart types that Excel recommends for your data.
|
||||
|
||||
Click any chart type to see how your data will look in that format.
|
||||
|
||||
When you find the chart type that you want, click it, and then click OK. We want to select the chart called Line. A line chart is used to display trends over time. We will use the line chart because there are many data points over time.
|
||||
|
||||
Tip: If you don’t see a chart type that you want, click the All Charts tab to see all of the available chart types.
|
||||
|
||||

|
||||
|
||||
* Use the Chart Elements, Chart Styles, and Chart Filters buttons next to the upper-right corner of the chart to add chart elements like axis titles or data labels, to customize the look of your chart
|
||||
|
||||

|
||||
|
||||
### ~
|
||||
Have fun reviewing your simulation and analyze the acceleration by chart the Excel data using Excel.
|
||||
|
||||
* Connect the first micro:bit to your computer using your USB cable and run the charting script on it.
|
||||
* Connect the second micro:bit to your computer using your USB cable and run the charting script on it.
|
||||
* The first person and second person take turns tilting the micro:bit in the "x" direction while the other player charts the data on the micro:bit!
|
||||
* Review and analyze the actual micro:bit device acceleration data on Excel
|
||||
* Display acceleration with y or z using plot bar graph by changing acceleration from "x" to "y" or "z"
|
||||
|
33
docs/lessons/charting/quiz-answers.md
Normal file
@ -0,0 +1,33 @@
|
||||
# charting quiz answers
|
||||
|
||||
Measure the acceleration on the micro:bit in the "x" direction.
|
||||
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [glowing pendulum activity](/lessons/charting/acceleration)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Why are you creating a 'forever' loop?
|
||||
|
||||
<br/>
|
||||
|
||||
We are creating a forever loop to constantly display the appropriate brightness on the LED display.
|
||||
|
||||
## 2. Write the line of code to measure the acceleration with respect to the "x" axis and display this value in a bar graph.
|
||||
|
||||
<br/>
|
||||
|
||||
```blocks
|
||||
led.plotBarGraph(input.acceleration(Dimension.X), 0)
|
||||
```
|
||||
|
||||
## 3. After vigarously moving the micro:bit from side to side along the "x" axis for a sufficient amount of time,insert the Excel graph for displaying a line chart used to display trends over time.
|
||||
|
||||
<br/>
|
||||
|
||||

|
||||
|
23
docs/lessons/charting/quiz.md
Normal file
@ -0,0 +1,23 @@
|
||||
# charting quiz
|
||||
|
||||
Measure the acceleration on the micro:bit in the "x" direction.
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [glowing pendulum tutorial](/lessons/glowing-pendulum/activity)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Why are you creating a 'forever' loop?
|
||||
|
||||
<br/>
|
||||
|
||||
## 2. Write the line of code to measure the acceleration with respect to the "y" axis and store this value in a local variable called 'acceleration'.
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. After vigarously moving the micro:bit from side to side along the "x" axis for a sufficient amount of time,insert the Excel graph for displaying a line chart used to display trends over time.
|
||||
|
||||
|
@ -17,7 +17,7 @@ input.onPinPressed(TouchPin.P1, () => {
|
||||
})
|
||||
```
|
||||
|
||||
**Challenge 1**
|
||||
### Challenge 1
|
||||
|
||||
Let's include a second sound `on pin pressed` *P2*. To do this, you need to add the same blocks as the banana keyboard activity. However, you must change alter `on pin pressed` from P1 to P2. Additionally, you must *decrease* the frequency of the variable "sound" by 25. Modify your code so that your code looks like this
|
||||
|
||||
@ -42,7 +42,7 @@ input.onPinPressed(TouchPin.P2, () => {
|
||||
|
||||
* click *run* to see if the code works as expected.
|
||||
|
||||
**Challenge 2**
|
||||
### Challenge 2
|
||||
|
||||
Finally, we want images to be displayed with sounds `on pin pressed`. Add `show LEDs` blocks under `on pin pressed` P1 and P2.
|
||||
|
||||
|
@ -42,7 +42,7 @@ input.onButtonPressed(Button.B, () => {
|
||||
|
||||
* `Run` the code to see if it works as expected.
|
||||
|
||||
**Challenge 3**
|
||||
### Challenge 3
|
||||
|
||||
When you are asked a yes or no question, do you always say yes or no? Add a condition for `on shake` that displays `TRY AGAIN`.
|
||||
|
||||
|
@ -9,6 +9,7 @@ Acceleration
|
||||
## Quick Links
|
||||
|
||||
* [activity](/lessons/glowing-pendulum/activity)
|
||||
* [tutorial](/lessons/glowing-pendulum/tutorial)
|
||||
* [challenges](/lessons/glowing-pendulum/challenges)
|
||||
* [quiz](/lessons/glowing-pendulum/quiz)
|
||||
* [quiz answers](/lessons/glowing-pendulum/quiz-answers)
|
||||
|
@ -4,10 +4,29 @@ Construct a pendulum that glows using acceleration.
|
||||
|
||||
Welcome! This activity will teach how to construct a pendulum that glows using acceleration. Let's get started!
|
||||
|
||||
Turn on all the LEDs.
|
||||
|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
`)
|
||||
```
|
||||
|
||||
Create a **forever** loop that will constantly display the appropriate brightness on the LED display.
|
||||
|
||||
|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
`)
|
||||
basic.forever(() => {
|
||||
|
||||
})
|
||||
@ -15,9 +34,14 @@ basic.forever(() => {
|
||||
|
||||
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.
|
||||
|
||||

|
||||
|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
`)
|
||||
basic.forever(() => {
|
||||
let acceleration = input.acceleration(Dimension.Y);
|
||||
});
|
||||
@ -25,27 +49,56 @@ basic.forever(() => {
|
||||
|
||||
Since the micro:bit will be swinging back and forth, the acceleration will only be positive half of the time. Thus, to always get a positive value, we want to take the absolute value of the acceleration.
|
||||
|
||||

|
||||
|
||||
```blocks
|
||||
let acceleration = 0;
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
`)
|
||||
basic.forever(() => {
|
||||
acceleration = input.acceleration(Dimension.Y);
|
||||
let acceleration = input.acceleration(Dimension.Y);
|
||||
acceleration = Math.abs(acceleration)
|
||||
});
|
||||
```
|
||||
|
||||
The function `acceleration(y)` returns a number between 0 and 1024. We want to use this value for the brightness of the micro:bit, but the `set brightness()` only accepts a value between 0 and 256. Thus, we need to divide the acceleration by 4 to ensure we will be in the appropriate range.
|
||||
|
||||

|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
`)
|
||||
basic.forever(() => {
|
||||
let acceleration = input.acceleration(Dimension.Y);
|
||||
acceleration = Math.abs(acceleration);
|
||||
acceleration = acceleration / 4;
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
Now let's use our acceleration value to set the brightness on the micro:bit.
|
||||
|
||||

|
||||
|
||||
Let's show what the brightness of the micro:bit is by turning all the LEDs on!
|
||||
|
||||

|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
`)
|
||||
basic.forever(() => {
|
||||
let acceleration = input.acceleration(Dimension.Y);
|
||||
acceleration = Math.abs(acceleration);
|
||||
acceleration = acceleration / 4;
|
||||
led.setBrightness(acceleration)
|
||||
});
|
||||
```
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
|
@ -6,15 +6,31 @@ Coding challenges for the glowing pendulum tutorial.
|
||||
|
||||
Complete the following [glowing pendulum activity](/lessons/glowing-pendulum/activity) and your code should look like this:
|
||||
|
||||

|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
let acceleration = input.acceleration(Dimension.Y);
|
||||
acceleration = Math.abs(acceleration);
|
||||
acceleration = acceleration / 4;
|
||||
led.setBrightness(acceleration)
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
`)
|
||||
});
|
||||
|
||||
**Challenge 1**
|
||||
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||

|
||||
|
||||
Hold the micro:bit in your hand in a dark room. Move the micro:bit like a pendulum and produce a slow image that captures the pattern of the micro:bit LEDs.
|
||||
|
||||
**Challenge 2**
|
||||
### Challenge 2
|
||||
|
||||
Replace "y" in `acceleration(y)` with "x" or "z". Changing the axis will cause the micro:bit to measure the force in a different direction. What differences in the resulting pattern does this replacement make?
|
||||
|
||||
|
@ -44,13 +44,3 @@ let accelerationDivided = accelerationX / 4
|
||||
led.setBrightness(accelerationX)
|
||||
```
|
||||
|
||||
## 5. Write the code that tuns all the LEDs on (as the image displays below)
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
```
|
||||
led.plotAll()
|
||||
```
|
||||
|
||||
|
@ -24,11 +24,4 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
|
||||
|
||||
## 4. Write the code to include acceleration value question 3 to set the brightness on the BBC micro:bit.
|
||||
|
||||
<br/>
|
||||
|
||||
## 5. Write the code that tuns all the LEDs on (as the image displays below)
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
|
29
docs/lessons/glowing-pendulum/tutorial.md
Normal file
@ -0,0 +1,29 @@
|
||||
# glowing pendulum block tutorial
|
||||
|
||||
The glowing pendulum changes the screen brightness based on the acceleration measured on the BBC micro:bit.
|
||||
|
||||
### Rebuild the game!
|
||||
|
||||
The blocks have been shuffled! Put them back together so that...
|
||||
* all LEDs are turned on
|
||||
* the BBC micro:bit repeats code **forever** that
|
||||
* reads the acceleration along the ``y`` axis,
|
||||
* calculate the absolute value of the acceleration
|
||||
* scales down the acceleration value by a factor of `4`
|
||||
* uses the scaled value to set the screen **brightness**
|
||||
|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
# # # # #
|
||||
`)
|
||||
basic.forever(() => {
|
||||
let acceleration = input.acceleration(Dimension.Y);
|
||||
acceleration = Math.abs(acceleration);
|
||||
acceleration = acceleration / 4;
|
||||
led.setBrightness(acceleration)
|
||||
});
|
||||
```
|
@ -11,6 +11,7 @@ Math - Pick Random
|
||||
## Quick links
|
||||
|
||||
* [activity](/lessons/guess-the-number/activity)
|
||||
* [tutorial](/lessons/guess-the-number/tutorial)
|
||||
* [challenges](/lessons/guess-the-number/challenges)
|
||||
* [quiz](/lessons/guess-the-number/quiz)
|
||||
* [quiz answers](/lessons/guess-the-number/quiz-answers)
|
||||
|
@ -19,12 +19,11 @@ input.onButtonPressed(Button.A, () => {
|
||||
|
||||
```
|
||||
|
||||
Create a local variable of type number `x` and set it to a random number using `pick random`. `pick random` 9 generates a random number between `0` and `09`.
|
||||
|
||||
Create a local variable of type number `x` and set it to a random number using `pick random`. `pick random` 9 generates a random number between `0` and `9`.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
let x = Math.random(9)
|
||||
let x = Math.random(10)
|
||||
})
|
||||
|
||||
```
|
||||
@ -34,7 +33,7 @@ Show the random number on the screen.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
let x = Math.random(9)
|
||||
let x = Math.random(10)
|
||||
basic.showNumber(x)
|
||||
})
|
||||
|
||||
|
25
docs/lessons/guess-the-number/tutorial.md
Normal file
@ -0,0 +1,25 @@
|
||||
# guess the number tutorial
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
### @video td/videos/guess-the-number-0
|
||||
|
||||
This tutorial will help you create a guess the number game! Let's get started!
|
||||
|
||||
### ~
|
||||
|
||||
### Rebuild the game!
|
||||
|
||||
The blocks have been shuffled! Put them back together so that...
|
||||
* when the user presses button ``A``,
|
||||
* generate a random number
|
||||
* show the number on screen
|
||||
|
||||
|
||||
```shuffle
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
let x = Math.random(10)
|
||||
basic.showNumber(x)
|
||||
})
|
||||
```
|
||||
|
@ -35,5 +35,5 @@ basic.showNumber(14)
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Keep displaying multiples of 7 such as 21 and 28, but don't forget to add pauses between the numbers!
|
||||
Keep displaying multiples of 7 such as 21 and 28...
|
||||
|
||||
|
@ -9,6 +9,7 @@ If (Conditionals)
|
||||
## Quick Links
|
||||
|
||||
* [activity](/lessons/magic-8/activity)
|
||||
* [tutorial](/lessons/magic-8/tutorial)
|
||||
* [challenges](/lessons/magic-8/challenges)
|
||||
* [quiz](/lessons/magic-8/quiz)
|
||||
* [quiz answers](/lessons/magic-8/quiz-answers)
|
||||
|
@ -1,8 +1,6 @@
|
||||
# magic 8 activity
|
||||
|
||||
A fortune teller game on the micro:bit
|
||||
|
||||
Welcome! This tutorial will help you create a magic 8 ball on the micro:bit. Let's get started!
|
||||
Welcome! This activity will help you create a magic 8 ball on the micro:bit. Let's get started!
|
||||
|
||||
Show a string to instruct the user how to play Magic 8! The magic 8 ball can only answer true or false questions.
|
||||
|
||||
@ -32,16 +30,13 @@ input.onGesture(Gesture.Shake, () => {
|
||||
Create a variable of type number called **randomNumber**. Set **randomNumber** to a random number with a limit of 2. Remember the random function in the math library, picks a random number from 0 to the limit, but not including the limit unless it is 0.
|
||||
|
||||
```blocks
|
||||
|
||||
basic.showString("ASK A QUESTION")
|
||||
basic.showNumber(8)
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
basic.clearScreen()
|
||||
let randomNumber = Math.random(2)
|
||||
let randomNumber = Math.random(3)
|
||||
|
||||
});
|
||||
|
||||
|
||||
```
|
||||
|
||||
Create an if statement for the condition `if randomNumber = 2`. If **randomNumber** is 2, display the string 'Yes'
|
||||
@ -52,7 +47,7 @@ basic.showString("ASK A QUESTION")
|
||||
basic.showNumber(8)
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
basic.clearScreen();
|
||||
let randomNumber = Math.random(2);
|
||||
let randomNumber = Math.random(3);
|
||||
if (randomNumber == 2) {
|
||||
basic.showString("YES");
|
||||
}
|
||||
@ -68,7 +63,7 @@ basic.showString("ASK A QUESTION")
|
||||
basic.showNumber(8)
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
basic.clearScreen()
|
||||
let randomNumber = Math.random(2)
|
||||
let randomNumber = Math.random(3)
|
||||
if (randomNumber == 2) {
|
||||
basic.showString("YES")
|
||||
} else if (randomNumber == 1) {
|
||||
@ -84,7 +79,7 @@ basic.showString("ASK A QUESTION")
|
||||
basic.showNumber(8)
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
basic.clearScreen()
|
||||
let randomNumber = Math.random(2)
|
||||
let randomNumber = Math.random(3)
|
||||
if (randomNumber == 2) {
|
||||
basic.showString("YES")
|
||||
} else if (randomNumber == 1) {
|
||||
@ -106,14 +101,13 @@ basic.showString("ASK A QUESTION")
|
||||
basic.showNumber(8)
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
basic.clearScreen()
|
||||
let randomNumber = Math.random(2)
|
||||
let randomNumber = Math.random(3)
|
||||
if (randomNumber == 2) {
|
||||
basic.showString("YES")
|
||||
} else if (randomNumber == 1) {
|
||||
basic.showString("NO")
|
||||
} else {
|
||||
basic.showString("I DON'T KNOW")
|
||||
|
||||
}
|
||||
basic.showNumber(8)
|
||||
|
||||
|
@ -26,7 +26,7 @@ input.onGesture(Gesture.Shake, () => {
|
||||
```
|
||||
|
||||
|
||||
**Challenge 1**
|
||||
### Challenge 1
|
||||
|
||||
Now let's increase the number of responses the magic 8 ball can give. How about 5 responses instead? Let's change the limit of `pick random` to 4.
|
||||
|
||||
@ -49,7 +49,7 @@ input.onGesture(Gesture.Shake, () => {
|
||||
})
|
||||
```
|
||||
|
||||
**Challenge 2**
|
||||
### Challenge 2
|
||||
|
||||
Now have the magic 8 ball respond "Try again" if **randomNumber** is 3.
|
||||
|
||||
@ -73,7 +73,7 @@ input.onGesture(Gesture.Shake, () => {
|
||||
})
|
||||
```
|
||||
|
||||
**Challenge 3**
|
||||
### Challenge 3
|
||||
|
||||
Now what about if **randomNumber** is 4? Let's have the magic 8 ball respond "Definitely!".
|
||||
|
||||
|
27
docs/lessons/magic-8/tutorial.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Magic 8 tutorial
|
||||
|
||||
Show a string to instruct the user how to play Magic 8! The magic 8 ball can only answer questions with "YES", "NO", or "MAYBE"...
|
||||
|
||||
### Rebuild the game!
|
||||
|
||||
The blocks have been shuffled! Put them back together so that...
|
||||
* show "ASK A QUESTION" on the screen
|
||||
* when the micro:bit is shaken,
|
||||
* generate a random number between 0 and 2.
|
||||
* if the number is `2`, show "YES"
|
||||
* if the number is `1`, show "NO"
|
||||
* otherwise show "MAYBE"...
|
||||
|
||||
```shuffle
|
||||
basic.showString("ASK A QUESTION")
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let randomNumber = Math.random(3)
|
||||
if (randomNumber == 2) {
|
||||
basic.showString("YES")
|
||||
} else if (randomNumber == 1) {
|
||||
basic.showString("NO")
|
||||
} else {
|
||||
basic.showString("MAYBE")
|
||||
}
|
||||
})
|
||||
```
|
@ -30,8 +30,6 @@ input.onGesture(Gesture.LogoUp, () => {
|
||||
. . # . .
|
||||
`)
|
||||
})
|
||||
|
||||
|
||||
```
|
||||
|
||||
Run your code and try to turn around the micro:bit to see the **logo up** event in action!
|
||||
|
@ -46,7 +46,7 @@ input.onButtonPressed(Button.B, () => {
|
||||
```
|
||||
|
||||
|
||||
**Challenge 3**
|
||||
### Challenge 3
|
||||
|
||||
Add an event handler with `on shake` to change the LED brightness back to a `255`.
|
||||
|
||||
|
@ -88,7 +88,7 @@ input.onButtonPressed(Button.B, () => {
|
||||
|
||||
* Run the code to see if it works as expected.
|
||||
|
||||
**Challenge 3**
|
||||
### Challenge 3
|
||||
|
||||
Now make sure the image does not go off the left side and if it does, prompt the user to push button `A`.
|
||||
|
||||
|
@ -42,7 +42,7 @@ basic.forever(() => {
|
||||
|
||||
```
|
||||
|
||||
**Challenge 1**
|
||||
### Challenge 1
|
||||
|
||||
What if wanted to show the maximum connectivity of wifi instead of just 1, 3, or 4 bars?
|
||||
|
||||
@ -86,7 +86,7 @@ basic.forever(() => {
|
||||
})
|
||||
```
|
||||
|
||||
**Challenge 2**
|
||||
### Challenge 2
|
||||
|
||||
Let's add an **IF** at the bottom of your code that checks to see if `sum >= to 1200` **and** if `sum <1400`
|
||||
|
||||
@ -135,7 +135,7 @@ basic.forever(() => {
|
||||
})
|
||||
```
|
||||
|
||||
**Challenge 3**
|
||||
### Challenge 3
|
||||
|
||||
Now it's your turn! Be creative and change the Wifi meter images to your own wifi image you're sure will prank your friends by editing the lines that call `showLeds()`.
|
||||
|
||||
|
@ -41,7 +41,7 @@ input.onButtonPressed(Button.A, () => {
|
||||
|
||||
```
|
||||
|
||||
**Challenge 1**
|
||||
### Challenge 1
|
||||
|
||||
Create an event handler for Button B.
|
||||
|
||||
@ -83,7 +83,7 @@ input.onButtonPressed(Button.B, () => {
|
||||
|
||||
```
|
||||
|
||||
**Challenge 2**
|
||||
### Challenge 2
|
||||
|
||||
### @video td/videos/screen-wipe-2
|
||||
|
||||
@ -155,7 +155,7 @@ basic.showLeds(`
|
||||
```
|
||||
|
||||
|
||||
**Challenge 3**
|
||||
### Challenge 3
|
||||
|
||||
Show an animation that scrolls back up when you press button "B".
|
||||
|
||||
|
34
docs/lessons/seismograph.md
Normal file
@ -0,0 +1,34 @@
|
||||
# Seismograph Lesson
|
||||
|
||||
Build a seismograph with household materials
|
||||
|
||||
## Topic
|
||||
|
||||
Acceleration & Analog Read Pin
|
||||
|
||||
## Quick Links
|
||||
|
||||
* [activity](/lessons/seismograph/activity)
|
||||
* [challenge](/lessons/seismograph/challenges)
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to **show LEDs** to turn on a LED light pattern on the LED screen. We will be learning basic comments such as show LEDs and pause.
|
||||
|
||||
## Documentation
|
||||
|
||||
```cards
|
||||
basic.forever(() => {
|
||||
});
|
||||
led.plotBarGraph(input.acceleration(Dimension.Strength) - 1023, 0);
|
||||
led.plotBarGraph(pins.analogReadPin(AnalogPin.P0), 0);
|
||||
|
||||
```
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to repeat code forever in the background
|
||||
* learn how to display a vertical bar graph based on the value.
|
||||
* learn how to return the sum of the two numbers
|
||||
* learn how to get acceleration value in milli-gravitys
|
||||
* learn how to read the connector value as analog as a value comprised between 0 and 1023
|
150
docs/lessons/seismograph/activity.md
Normal file
@ -0,0 +1,150 @@
|
||||
# Seismograph Activity
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
In this project, you will build your own seismograph.
|
||||
|
||||
## What you'll need:
|
||||
|
||||
* micro:bit
|
||||
* USB cable
|
||||
* Scissors
|
||||
* Glue gun
|
||||
* String
|
||||
* Cup (Plastic or Paper)
|
||||
* Magnet
|
||||
|
||||
Welcome! This activity will teach how to use the micro:bit to chart the strength of the acceleration. Let's get started!
|
||||
|
||||
1. Setup Cup: Use scissors to cut a usable window on the cup, which will be a square sized hole at the lid side of the cup. Use scissors to create a small hole in the center of the base of the cup.
|
||||
|
||||
2. Fasten Magnet: Fasten end of the string to the magnet with glue
|
||||
|
||||
3. Secure String: Fasten string to base of the cup and hang the remaining string outside the base of the cup.
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Seismograph built, let's code!
|
||||
|
||||
### ~
|
||||
|
||||
4. Go to Codemicrobit.com
|
||||
|
||||
Click or tap Create Code
|
||||
Click or tap Block Editor
|
||||
|
||||
### ~
|
||||
|
||||
5.
|
||||
|
||||
We will measure `acceleration (mg)` in terms of strength. Get the acceleration value (milli g-force), as measured in strength.
|
||||
|
||||
```blocks
|
||||
input.acceleration(Dimension.Strength);
|
||||
```
|
||||
|
||||
### ~
|
||||
|
||||
6.
|
||||
|
||||
Use the plot bar chart to visualize the acceleration on the LED screen of the micro:bit in the specified range. You implement plot Bar Graph to display a vertical bar graph based on the "value" and "high" value. Then you must insert acceleration in based on strength.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
led.plotBarGraph(input.acceleration(Dimension.Strength), 0);
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
### ~
|
||||
|
||||
7.
|
||||
|
||||
Finally, we subtract the gravity from acceleration strength.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
led.plotBarGraph(input.acceleration(Dimension.Strength) - 1023, 0);
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
### ~
|
||||
|
||||
8.
|
||||
|
||||
Notice that making vibrating the object below the micro:bit changes the values and the line appears as a wave to display the value of the strength as measured in milli-gravities. By making the object below the micro:bit vibrate, you will observe changing values of the micro:bit. Also, the LEDs shown on the Bar Graph fluctates based on the movement of the micro:bit strength.
|
||||
|
||||
NOTE: The black color reflects the micro:bit device.
|
||||
|
||||

|
||||
|
||||
|
||||
### ~
|
||||
|
||||
9.
|
||||
|
||||
Vigorously move the micro:bit in the micro:bit simulatator by moving the micro:bit image from side to side. Every time the micro:bit moves in the x direction in the simulator, you are generating data points that can be reviewed in Excel. The more attempts to move the micro:bit from side to side, the more data being saved in Excel. After you have vigarously moved the micro:bit simulator from side to side for a sufficient amount of time, you are ready to graph or chart the accceleration of the micro:bit. We want a printout of our acceleration on Excel that can be graphed in Excel.
|
||||
|
||||
|
||||
### ~
|
||||
|
||||
10.
|
||||
|
||||
We want to chart the data collected by using a tool in Excel.
|
||||
|
||||
The final part of this experiment is opening and reviewing the data in the Excel CSV file. Simply click on the line beneath the simulator. A CSV file will be generated to display the data points collected by moving the micro:bit in the X direction. Then click or tap on the data Excel file that was downloaded to your local Downloads Folder.
|
||||
|
||||
|
||||
### ~
|
||||
|
||||
10.
|
||||
|
||||
|
||||
First, click or tap on the first two columns (A, B) to include the time of the data being collected; b) the results of acceleration data on the micro:bit
|
||||
|
||||

|
||||
|
||||
Use the Recommended Charts command on the Insert tab to quickly create a chart that’s just right for your data.
|
||||
|
||||
* Select the data that you want to include in your chart.
|
||||
|
||||
* Click Insert > Recommended Charts.
|
||||
|
||||
### ~
|
||||
|
||||
11.
|
||||
|
||||
|
||||

|
||||
|
||||
* On the Recommended Charts tab, scroll through the list of chart types that Excel recommends for your data.
|
||||
|
||||
Click any chart type to see how your data will look in that format.
|
||||
|
||||
When you find the chart type that you want, click it, and then click OK. We want to select the chart called Line. A line chart is used to display trends over time. We will use the line chart because there are many data points over time.
|
||||
|
||||
Tip: If you don’t see a chart type that you want, click the All Charts tab to see all of the available chart types.
|
||||
|
||||
### ~
|
||||
|
||||
12.
|
||||
|
||||

|
||||
|
||||
* Use the Chart Elements, Chart Styles, and Chart Filters buttons next to the upper-right corner of the chart to add chart elements like axis titles or data labels, to customize the look of your chart
|
||||
|
||||
### ~
|
||||
|
||||
13.
|
||||
|
||||

|
||||
|
||||
* Connect a micro:bit to your computer using your USB cable; compile; and repeat this experiment by vibrating the micro:bit. Then chart the data on Excel.
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/lessons/seismograph/challenge)
|
||||
|
||||
### ~
|
||||
|
94
docs/lessons/seismograph/challenge.md
Normal file
@ -0,0 +1,94 @@
|
||||
# Challenge
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Welcome! The activity will teach you how to use the acceleration of the 1st micro:bit and to visualize the acceleration on the 2nd micro:bit. Let's get started!
|
||||
|
||||
### ~
|
||||
Let's measure `acceleration (mg)` and then `send number`. `Acceleration` is measured in **milli-gravities**, so a value of -1000 is equivalent to -1g or -9.81m/s^2. We will be able to get the acceleration value (g-force), in the specified "x" dimension. `Send number` will broadcast a number data packet to other micro:bits connected via radio.
|
||||
|
||||
```blocks
|
||||
radio.sendNumber(input.acceleration(Dimension.X));
|
||||
```
|
||||
### ~
|
||||
We want to display the acceleration forever. In order to do so, we need a `forever` loop. A forever loop will repeat code in the background forever.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
radio.sendNumber(input.acceleration(Dimension.X));
|
||||
});
|
||||
|
||||
|
||||
```
|
||||
### ~
|
||||
We want to register code to run when a packet is received over radio. We can implement this code by adding `on data received`.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
radio.sendNumber(input.acceleration(Dimension.X))
|
||||
})
|
||||
radio.onDataReceived(() => {
|
||||
|
||||
})
|
||||
```
|
||||
### ~
|
||||
Finally, we want to chart the acceleration. So we must first implement `plot bar graph`. `Plot Bar Graph` will display a vertical bar graph based on the value and high value. In order to transfer the receive the number from the 1st micro:bit, we must implement `receive number` to constantly display a vertical bar graph based on the value. Remember, the value will equal to the micro:bit's acceleration in the "x" direction.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
radio.sendNumber(input.acceleration(Dimension.X))
|
||||
})
|
||||
radio.onDataReceived(() => {
|
||||
led.plotBarGraph(radio.receiveNumber(), 1023)
|
||||
})
|
||||
|
||||
```
|
||||
### ~
|
||||
Notice that moving the micro:bit the farthest direction in the x direction will be -1023 on the charting beneath the simulator. The second observation will be that the LEDs will be full brightness on the 2nd micro:bit. There is a single LED turned on with the 1st micro:bit. Additionally, the graphs will reflect 0 acceleation for the 1st micro:bit. In this scenario, if you are adjusting the acceleration in the simualator, you are also changing your chart that will be produced.
|
||||
|
||||

|
||||
|
||||
### ~
|
||||
NOTE: The colors of the charts reflect the color of the micro:bit simulator. In this instance, the micro:bits are blue and green. So the colors of the line graphs reflect the colors of the micro:bit
|
||||
|
||||
### ~
|
||||
After running this simulatation several seconds by moving the micro:bit side to side in the x direction, you are ready to graph or chart the accceleration of the micro:bit. We want a printout of our acceleration on Excel. We will graph the fluctuating acceleration of the simulation experiment.
|
||||
|
||||

|
||||
|
||||
### ~
|
||||
Finally, you must open the Excel CSV file by clicking on the data.xls file that was downloaded to Downloads Folder.
|
||||
|
||||

|
||||
|
||||
Use the Recommended Charts command on the Insert tab to quickly create a chart that’s just right for your data.
|
||||
|
||||
* Select the data that you want to include in your chart.
|
||||
|
||||
* Click Insert > Recommended Charts.
|
||||
|
||||

|
||||
|
||||
* On the Recommended Charts tab, scroll through the list of chart types that Excel recommends for your data.
|
||||
|
||||
Click any chart type to see how your data will look in that format.
|
||||
|
||||
When you find the chart type that you want, click it, and then click OK. We want to select the chart called Line. A line chart is used to display trends over time. We will use the line chart because there are many data points over time.
|
||||
|
||||
Tip: If you don’t see a chart type that you want, click the All Charts tab to see all of the available chart types.
|
||||
|
||||

|
||||
|
||||
* Use the Chart Elements, Chart Styles, and Chart Filters buttons next to the upper-right corner of the chart to add chart elements like axis titles or data labels, to customize the look of your chart
|
||||
|
||||

|
||||
|
||||
### ~
|
||||
Have fun reviewing your simulation and analyze the acceleration by chart the Excel data using Excel.
|
||||
|
||||
* Connect the first micro:bit to your computer using your USB cable and run the charting script on it.
|
||||
* Connect the second micro:bit to your computer using your USB cable and run the charting script on it.
|
||||
* The first person and second person take turns tilting the micro:bit in the "x" direction while the other player charts the data on the micro:bit!
|
||||
* Review and analyze the actual micro:bit device acceleration data on Excel
|
||||
* Display acceleration with y or z using plot bar graph by changing acceleration from "x" to "y" or "z"
|
||||
|
@ -11,6 +11,7 @@ If (Conditionals)
|
||||
## Quick Links
|
||||
|
||||
* [activity](/lessons/truth-or-dare/activity)
|
||||
* [tutorial](/lessons/truth-or-dare/tutorial)
|
||||
* [challenges](/lessons/truth-or-dare/challenges)
|
||||
* [quiz](/lessons/truth-or-dare/quiz)
|
||||
* [quiz answers](/lessons/truth-or-dare/quiz-answers)
|
||||
|
63
docs/lessons/truth-or-dare/tutorial.md
Normal file
@ -0,0 +1,63 @@
|
||||
# truth or dare tutorial
|
||||
|
||||
### ~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"
|
||||
to see if she has to provide a *truth* or a *dare*.
|
||||
|
||||
### ~
|
||||
|
||||
### Rebuild the game!
|
||||
|
||||
The blocks have been shuffled! Put them back together so that...
|
||||
* an up arrow is displayed when the micro:bit is powered on.
|
||||
* on button `A` is pressed,
|
||||
* randomly display "TRUTH" or "DARE" on the screen
|
||||
* show the up arrow again.
|
||||
|
||||
```shuffle
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
let random = Math.random(2)
|
||||
if (random == 0) {
|
||||
basic.showString("TRUTH")
|
||||
} else {
|
||||
basic.showString("DARE")
|
||||
}
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# # # # #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`)
|
||||
})
|
||||
```
|
||||
### Hints and tips
|
||||
Cut out these documentation cards to help you!
|
||||
|
||||
```cards
|
||||
basic.showLeds(`
|
||||
. . # . .
|
||||
. # # # .
|
||||
# . # . #
|
||||
. . # . .
|
||||
. . # . .
|
||||
`);
|
||||
Math.random(2);
|
||||
basic.showString("TRUTH");
|
||||
if (true) {} else {}
|
||||
"TRUTH";
|
||||
0;
|
||||
input.onButtonPressed(Button.A, () => {});
|
||||
```
|
||||
|
9
docs/open-source.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Open Source
|
||||
|
||||
The editor is open source on GitHub under the MIT license. Contributions are welcome, please check our GitHub repos.
|
||||
|
||||
### Repos
|
||||
|
||||
* [microbit/pxt](https://github.com/Microsoft/pxt), programming experience toolkit (PXT)
|
||||
* [microsoft/pxt-microbit](https://github.com/Microsoft/pxt-microbit), PXT target for BBC micro:bit
|
||||
* [microsoft/pxt-microbit-core](https://github.com/Microsoft/pxt-microbit-core), Yotta module used to build the BBC micro:bit runtime
|
14
docs/packages.md
Normal file
@ -0,0 +1,14 @@
|
||||
# Extensions
|
||||
|
||||
You can publish libraries (also known as packages or extensions)
|
||||
that users can then add to their scripts. These typically
|
||||
provide a driver for a particular hardware device you can connect
|
||||
to a microbit.
|
||||
|
||||
* [Sample C++ extension](https://github.com/Microsoft/pxt-microbit-cppsample)
|
||||
* [Sample TypeScript extension](https://github.com/Microsoft/pxt-microbit/tree/master/libs/i2c-fram)
|
||||
|
||||
## Finding libraries
|
||||
|
||||
## Publishing libraries
|
||||
|
@ -1,17 +1,28 @@
|
||||
# Reference
|
||||
|
||||
```namespaces
|
||||
basic.showString("Hello!");
|
||||
input.onButtonPressed(Button.A, () => {});
|
||||
for (let i = 0;i<5;++i) {}
|
||||
if (true){}
|
||||
let x = 0;
|
||||
Math.random(5);
|
||||
led.plot(0,0);
|
||||
basic.showNumber(0);
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
|
||||
});
|
||||
music.playTone(0, 0);
|
||||
led.plot(0, 0);
|
||||
radio.sendNumber(0);
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Whole));
|
||||
game.createSprite(2,2);
|
||||
game.addScore(1);
|
||||
images.createImage(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . # . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`);
|
||||
pins.digitalReadPin(DigitalPin.P0);
|
||||
serial.writeLine("Hello!");
|
||||
control.inBackground(() => {});
|
||||
serial.writeValue(x, 0);
|
||||
control.inBackground(() => {
|
||||
|
||||
});
|
||||
```
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
Provides access to basic micro:bit functionality.
|
||||
|
||||
|
||||
```cards
|
||||
basic.showNumber(0);
|
||||
basic.showLeds(`
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Show Animation
|
||||
|
||||
Show a series of image frames on the [LED screen](/device/screen), pausing the specified time after each frame.
|
||||
Show a group of image frames (pictures) one after another on the [LED screen](/device/screen). It pauses the amount of time you tell it after each frame.
|
||||
|
||||
```sig
|
||||
basic.showAnimation(`
|
||||
@ -14,10 +14,14 @@ basic.showAnimation(`
|
||||
|
||||
### Parameters
|
||||
|
||||
* `leds` - [String](/reference/types/string); a series of LED on/off states
|
||||
* `interval` - [Number](/reference/types/number); the number of milliseconds to pause after each image frame
|
||||
* `leds` is a [String](/reference/types/string) that shows which LEDs are on and off, in groups one after another.
|
||||
* `interval` is an optional [Number](/reference/types/number). It means the number of milliseconds to pause after each image frame.
|
||||
|
||||
### Show a series of image frames
|
||||
### Example: Animating a group of image frames
|
||||
|
||||
In this animation, each row is 15 spaces wide because
|
||||
there are three frames in the animation, and each frame is
|
||||
five spaces wide, just like the screen on the BBC micro:bit.
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
@ -31,13 +35,17 @@ basic.showAnimation(`
|
||||
|
||||
### ~hint
|
||||
|
||||
If the series of images appear too fast, increase the value of the *interval* parameter.
|
||||
If the animation is too fast, make `interval` bigger.
|
||||
|
||||
### ~
|
||||
|
||||
### Example: animating frames
|
||||
### Example: animating frames with a pause
|
||||
|
||||
The following example creates an image with six frames and then shows each frame o the screen, pausing 500 milliseconds after each frame:
|
||||
This example shows six frames on the screen, pausing 500 milliseconds after each frame.
|
||||
|
||||
In this animation, each row is 30 spaces wide because
|
||||
there are six frames in the animation, and each frame is
|
||||
five spaces wide, just like the screen.
|
||||
|
||||
```
|
||||
basic.showAnimation(`
|
||||
@ -51,7 +59,7 @@ basic.showAnimation(`
|
||||
|
||||
### ~hint
|
||||
|
||||
Use [forever](/reference/basic/forever) to continually repeat an animation
|
||||
Use [forever](/reference/basic/forever) to show an animation over and over.
|
||||
|
||||
### ~
|
||||
|
||||
|
@ -15,12 +15,13 @@ basic.showLeds(`
|
||||
|
||||
### Parameters
|
||||
|
||||
* ``leds`` - a series of LED on/off states that form an image (see steps below)
|
||||
* (optional) ``ms`` - [Number](/reference/types/number) - time to wait after displaying image. In blocks, ``ms`` is 400 by default.
|
||||
* `leds` is a [String](/reference/types/string) that shows which LEDs are on and off.
|
||||
* `ms` is an optional [Number](/reference/types/number) that shows how many milliseconds to wait after showing a picture.
|
||||
If you are programming with blocks, `ms` starts out as 400 milliseconds.
|
||||
|
||||
### Example - Block Editor
|
||||
### Example
|
||||
|
||||
1. Open the `basic` category and select the `show leds` blocks.
|
||||
Open the `basic` card in the Block Editor and select the `show leds` blocks.
|
||||
|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
@ -33,7 +34,7 @@ basic.showLeds(`
|
||||
)
|
||||
```
|
||||
|
||||
In JavaScript, the led off is represented by a `.` and the led on by a `#` character.
|
||||
If you are programming in JavaScript, `#` means an LED that is turned on and `.` means an LED that is turned off.
|
||||
|
||||
### Lessons
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Show Number
|
||||
|
||||
Show a number on the [LED screen](/device/screen), one digit at a time (scrolling from left to right)
|
||||
Show a number on the [LED screen](/device/screen). It will slide left if it has more than one digit.
|
||||
|
||||
~~~~sig
|
||||
basic.showNumber(2, 150)
|
||||
@ -8,18 +8,18 @@ basic.showNumber(2, 150)
|
||||
|
||||
### Parameters
|
||||
|
||||
* value - a [Number](/reference/types/number)
|
||||
* (optional) interval (ms) - [Number](/reference/types/number); the time (in milliseconds) before scrolling by one LED; the larger the number, the slower the scroll
|
||||
* `value` is a [Number](/reference/types/number).
|
||||
* `interval` is an optional [Number](/reference/types/number). It means the number of milliseconds before sliding the `value` left by one LED each time. Bigger intervals make the sliding slower.
|
||||
|
||||
### ~
|
||||
### Examples:
|
||||
|
||||
To display the number 10:
|
||||
To show the number 10:
|
||||
|
||||
~~~~blocks
|
||||
basic.showNumber(10)
|
||||
~~~~
|
||||
|
||||
To display the number stored in the `x` variable:
|
||||
To show the number stored in a variable:
|
||||
|
||||
~~~~blocks
|
||||
let x = 1
|
||||
@ -28,19 +28,19 @@ basic.showNumber(x)
|
||||
|
||||
### Example: count to 5
|
||||
|
||||
This example uses a [for](/reference/loops/for) loop to show numbers ``1`` through ``5`` on the screen:
|
||||
This example uses a [for](/reference/loops/for) loop to show numbers ``0`` through ``5`` on the screen:
|
||||
|
||||
~~~~blocks
|
||||
for (let i = 0; i < 5; i++) {
|
||||
basic.showNumber(i + 1)
|
||||
for (let i = 0; i < 6; i++) {
|
||||
basic.showNumber(i)
|
||||
basic.pause(200)
|
||||
}
|
||||
~~~~
|
||||
|
||||
### Other show functions
|
||||
|
||||
* use [show string](/reference/basic/show-string) to show a string on the screen
|
||||
* use [show animation](/reference/basic/show-animation) to show a series of images on the screen
|
||||
* Use [show string](/reference/basic/show-string) to show a [String](/reference/types/string) with letters on the screen.
|
||||
* Use [show animation](/reference/basic/show-animation) to show a group of pictures on the screen, one after another.
|
||||
|
||||
### Lessons
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Show String
|
||||
|
||||
Show a string on the [LED screen](/device/screen) one character at a time (scrolling from left to right).
|
||||
Show a number on the [LED screen](/device/screen). It will slide left if it is bigger than the screen.
|
||||
|
||||
```sig
|
||||
basic.showString("Hello!")
|
||||
@ -8,18 +8,18 @@ basic.showString("Hello!")
|
||||
|
||||
### Parameters
|
||||
|
||||
* `text` - a [String](/reference/types/string)
|
||||
* (optional) `ms` - [Number](/reference/types/number); the time (in milliseconds) before scrolling left by one LED; the larger the number, the slower the scroll
|
||||
* `text` is a [String](/reference/types/string). It can contain letters, numbers, and punctuation.
|
||||
* `ms` is an optional [Number](/reference/types/number). It means the number of milliseconds before sliding the [String](/reference/types/string) left by one LED each time. Bigger intervals make the sliding slower.
|
||||
|
||||
### Examples:
|
||||
|
||||
To display Hello:
|
||||
To show the word **Hello**:
|
||||
|
||||
```blocks
|
||||
basic.showString("Hello")
|
||||
```
|
||||
|
||||
To display the content of a string variable:
|
||||
To show what is stored in a [String](/reference/types/string) variable:
|
||||
|
||||
```blocks
|
||||
let s = "Hi"
|
||||
@ -28,8 +28,8 @@ basic.showString(s)
|
||||
|
||||
### Other show functions
|
||||
|
||||
* use [show number](/reference/basic/show-number) to show a number on the screen
|
||||
* use [show animation](/reference/basic/show-animation) to show a series of images on the screen
|
||||
* Use [show number](/reference/basic/show-number) to show a number on the [LED screen](/device/screen).
|
||||
* Use [show animation](/reference/basic/show-animation) to show a group of pictures on the screen, one after another.
|
||||
|
||||
### Lessons
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
# Control
|
||||
|
||||
|
||||
|
||||
Runtime and event utilities.
|
||||
|
||||
```cards
|
||||
control.inBackground(() => {
|
||||
|
@ -1,7 +1,6 @@
|
||||
# Game
|
||||
|
||||
|
||||
|
||||
A single-LED sprite game engine
|
||||
|
||||
```cards
|
||||
game.addScore(1);
|
||||
|
@ -1,7 +1,6 @@
|
||||
# Images
|
||||
|
||||
|
||||
|
||||
Creation, manipulation and display of LED images.
|
||||
|
||||
```cards
|
||||
images.createImage(`
|
||||
|
@ -1,7 +1,6 @@
|
||||
# Input
|
||||
|
||||
|
||||
|
||||
Events and data from sensors
|
||||
|
||||
```cards
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
|
@ -1,7 +1,6 @@
|
||||
# Led
|
||||
|
||||
|
||||
|
||||
Control of the LED screen.
|
||||
|
||||
```cards
|
||||
led.plot(0, 0);
|
||||
@ -10,7 +9,7 @@ led.point(0, 0);
|
||||
led.brightness();
|
||||
led.setBrightness(255);
|
||||
led.stopAnimation();
|
||||
led.plotBarGraph(0, 1023);
|
||||
led.plotBarGraph(0, 0);
|
||||
led.fadeIn();
|
||||
led.fadeOut();
|
||||
led.plotAll();
|
||||
|
@ -1,39 +1,9 @@
|
||||
# Logic
|
||||
|
||||
[if](/reference/logic/if)
|
||||
|
||||
```blocks
|
||||
if(true) {
|
||||
}
|
||||
```
|
||||
|
||||
[Boolean](/reference/types/boolean) values: *true*; *false*
|
||||
|
||||
```blocks
|
||||
true
|
||||
false
|
||||
```
|
||||
|
||||
Boolean binary operators: *and* (conjunction); *or* (disjunction)
|
||||
|
||||
```blocks
|
||||
```cards
|
||||
if(true) {}
|
||||
true;
|
||||
true && false;
|
||||
true || false;
|
||||
```
|
||||
|
||||
Boolean negation operator
|
||||
|
||||
```blocks
|
||||
!true
|
||||
```
|
||||
|
||||
Comparison operators (=, !=, <, >, <=, >=)
|
||||
|
||||
```blocks
|
||||
0 == 0;
|
||||
1 !- 0;
|
||||
0 < 1;
|
||||
1 > 0;
|
||||
0 <= 1;
|
||||
1 >= 0;
|
||||
!true;
|
||||
1 != 0;
|
||||
```
|
||||
|
@ -1,23 +1,26 @@
|
||||
# If
|
||||
|
||||
Run code based on a condition.
|
||||
|
||||
### @parent blocks/language
|
||||
|
||||
|
||||
Conditionally run code depending on whether a [Boolean](/reference/types/boolean) condition is true or false.
|
||||
|
||||
### Block Editor
|
||||
|
||||

|
||||
```blocks
|
||||
if(true) {
|
||||
}
|
||||
```
|
||||
|
||||
In the Block Editor, click on the dark blue gear icon (see above) to add an *else* or *if* to the current block.
|
||||
|
||||
### Example: adjusting screen brightness
|
||||
|
||||

|
||||
```blocks
|
||||
if(input.lightLevel()<100){
|
||||
led.setBrightness(255);
|
||||
}
|
||||
```
|
||||
|
||||
If the screen [brightness](/reference/led/brightness) is `< 100`, this code sets the brightness to `255`:
|
||||
If the [light level](/input/light-level) is `< 100`, this code sets the brightness to `255`:
|
||||
|
||||
### Lessons
|
||||
|
||||
|
@ -1,26 +1,8 @@
|
||||
# Loops
|
||||
|
||||
Repeat code.
|
||||
|
||||
|
||||
[for](/reference/loops/for)
|
||||
|
||||
```blocks
|
||||
```cards
|
||||
for(let i = 0;i<5;i++) {}
|
||||
```
|
||||
|
||||
[repeat](/reference/loops/repeat)
|
||||
|
||||

|
||||
|
||||
[while](/reference/loops/while)
|
||||
|
||||
```blocks
|
||||
for(let i = 1;i<5;i++) {}
|
||||
while(true) {}
|
||||
```
|
||||
|
||||
[forever](/reference/basic/forever)
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {})
|
||||
```
|
||||
|
@ -1,15 +1,13 @@
|
||||
# For
|
||||
|
||||
Repeat code a preset number of times.
|
||||
|
||||
### @parent blocks/language
|
||||
|
||||
|
||||
Repeat code a fixed number of times.
|
||||
|
||||
### Block Editor
|
||||
|
||||

|
||||
```blocks
|
||||
for(let i = 0; i < 5; ++i) {
|
||||
}
|
||||
```
|
||||
|
||||
The Block Editor *for* loop is different than the Touch Develop *for* loop in an important way. The above for loop will iterate *five* times, with the loop variable *i* taking on values 0, 1, 2, 3, and 4. The Touch Develop for loop shown below will iterate four times:
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
Repeat code a preset number of times.
|
||||
|
||||
Repeat code a fixed number of times.
|
||||
|
||||
### Block Editor
|
||||
|
||||

|
||||
|
@ -1,23 +1,14 @@
|
||||
# While
|
||||
|
||||
Repeat code in a loop while a condition is true.
|
||||
|
||||
### @parent blocks/language
|
||||
|
||||
|
||||
Repeat code while a [Boolean](/reference/types/boolean) `condition` is true.
|
||||
|
||||
### ~hide
|
||||
|
||||
```blocks
|
||||
while(true) {
|
||||
}
|
||||
```
|
||||
let condition = false
|
||||
```
|
||||
|
||||
### ~
|
||||
|
||||
### Block Editor
|
||||
|
||||

|
||||
|
||||
The while loop has a *condition* that evaluates to a [Boolean](/reference/types/boolean) value. After the `do` keyword, add the code that you want to run while the `condition` is `true`. The while loop concludes with `end while`.
|
||||
|
||||
@ -27,11 +18,13 @@ The condition is tested before any code runs. Which means that if the condition
|
||||
|
||||
The following example uses a while loop to make a diagonal line on the LED screen (points `0, 0`, `1, 1`, `2, 2`, `3, 3`, `4, 4`).
|
||||
|
||||
// index is set to 4
|
||||
|
||||

|
||||
|
||||
// subtract 1 from `index` each time through loop
|
||||
```blocks
|
||||
let index = 4;
|
||||
while(index >= 0) {
|
||||
led.plot(index, index);
|
||||
index--;
|
||||
}
|
||||
```
|
||||
|
||||
### Lessons
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
# Music
|
||||
|
||||
|
||||
|
||||
Generation of music tones through pin ``P0``.
|
||||
|
||||
```cards
|
||||
music.playTone(0, 0);
|
||||
music.ringTone(0);
|
||||
music.rest(0);
|
||||
music.noteFrequency(Note.C);
|
||||
music.beat();
|
||||
music.beat(BeatFraction.Whole);
|
||||
music.tempo();
|
||||
music.changeTempoBy(20);
|
||||
music.setTempo(120);
|
||||
|
@ -4,7 +4,7 @@ The micro:bit pins.
|
||||
|
||||
## How to work offline
|
||||
|
||||
If you have loaded the web app at some time in the past (by clicking on "my scripts" from the home page), then if you later open the same browser (whether you are online or offline) and type in [https://codemicrobit.com/](https://codemicrobit.com/), you will be able to access all the features of the web app. Note that it is important to end the URL with "/".
|
||||
If you have loaded the web app at some time in the past (by clicking on "my scripts" from the home page), then if you later open the same browser (whether you are online or offline) and type in [https://m.pxt.io/](https://m.pxt.io/), you will be able to access all the features of the web app. Note that it is important to end the URL with "/".
|
||||
|
||||
## Save and load code using files
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
# Pins
|
||||
|
||||
|
||||
|
||||
Control currents in Pins for analog/digital signals, servos, i2c, ...
|
||||
|
||||
```cards
|
||||
pins.digitalReadPin(DigitalPin.P0);
|
||||
@ -9,8 +8,14 @@ pins.digitalWritePin(DigitalPin.P0, 0);
|
||||
pins.analogReadPin(AnalogPin.P0);
|
||||
pins.analogWritePin(AnalogPin.P0, 1023);
|
||||
pins.analogSetPeriod(AnalogPin.P0, 20000);
|
||||
pins.onPulsed(DigitalPin.P0, PulseValue.High, () => {
|
||||
|
||||
});
|
||||
pins.pulseDuration();
|
||||
pins.servoWritePin(AnalogPin.P0, 180);
|
||||
pins.servoSetPulse(AnalogPin.P0, 1500);
|
||||
pins.i2cReadNumber(0, NumberFormat.Int8LE);
|
||||
pins.i2cWriteNumber(0, 0, NumberFormat.Int8LE);
|
||||
pins.map(0, 0, 1023, 0, 4);
|
||||
pins.analogPitch(0, 0);
|
||||
pins.analogSetPitchPin(AnalogPin.P0);
|
||||
|
@ -1,17 +1,20 @@
|
||||
# Radio
|
||||
|
||||
|
||||
|
||||
Communicate data using radio packets
|
||||
|
||||
```cards
|
||||
radio.sendNumber(0);
|
||||
radio.sendNumbers(0, 0, 0, 0);
|
||||
radio.sendValue("data", 0);
|
||||
radio.sendString("");
|
||||
radio.onDataReceived(() => {
|
||||
|
||||
});
|
||||
radio.receiveNumber();
|
||||
radio.receivedNumberAt(0);
|
||||
radio.receiveString();
|
||||
radio.receivedSignalStrength();
|
||||
radio.setGroup(0);
|
||||
radio.setTransmitPower(0);
|
||||
radio.writeValueToSerial();
|
||||
radio.setTransmitSerialNumber(true);
|
||||
```
|
||||
|
@ -1,8 +1,11 @@
|
||||
# Serial
|
||||
|
||||
[Serial communication](/device/serial) between the BBC micro:bit and another computer.
|
||||
Reading and writing data over a serial connection.
|
||||
|
||||
```cards
|
||||
serial.writeLine("");
|
||||
serial.writeValue("x", 0);
|
||||
serial.writeNumber(0);
|
||||
serial.writeValue(x, 0);
|
||||
serial.writeString("");
|
||||
serial.readLine();
|
||||
```
|
||||
|
197
docs/reference/toc.md
Normal file
@ -0,0 +1,197 @@
|
||||
acceleration
|
||||
|
||||
analog-pitch
|
||||
|
||||
analog-read-pin
|
||||
|
||||
analog-set-period
|
||||
|
||||
analog-set-pitch-pin
|
||||
|
||||
analog-write-pin
|
||||
|
||||
assign
|
||||
|
||||
boolean
|
||||
|
||||
brightness
|
||||
|
||||
button-is-pressed
|
||||
|
||||
change
|
||||
|
||||
change-score-by
|
||||
|
||||
change-tempo
|
||||
|
||||
change-var
|
||||
|
||||
clear
|
||||
|
||||
clear-screen
|
||||
|
||||
compass-heading
|
||||
|
||||
create-image
|
||||
|
||||
digital-read-pin
|
||||
|
||||
digital-write-pin
|
||||
|
||||
fade-in
|
||||
|
||||
fade-out
|
||||
|
||||
for
|
||||
|
||||
forever
|
||||
|
||||
game-library
|
||||
|
||||
game-over
|
||||
|
||||
if
|
||||
|
||||
image
|
||||
|
||||
in-background
|
||||
|
||||
light-level
|
||||
|
||||
magnetic-force
|
||||
|
||||
map
|
||||
|
||||
math
|
||||
|
||||
move
|
||||
|
||||
number
|
||||
|
||||
[on button pressed](/reference/input/on-button-pressed)
|
||||
|
||||
on-data-received
|
||||
|
||||
on-gamepad-button
|
||||
|
||||
on-gesture
|
||||
|
||||
on-pin-pressed
|
||||
|
||||
on-signal-strength-changed
|
||||
|
||||
pause
|
||||
|
||||
pin-is-pressed
|
||||
|
||||
pixel
|
||||
|
||||
play-tone
|
||||
|
||||
plot
|
||||
|
||||
plot-all
|
||||
|
||||
plot-bar-graph
|
||||
|
||||
plot-frame
|
||||
|
||||
plot-image
|
||||
|
||||
plot-leds
|
||||
|
||||
point
|
||||
|
||||
position
|
||||
|
||||
raise-alert-to
|
||||
|
||||
receive-number
|
||||
|
||||
receive-number
|
||||
|
||||
repeat
|
||||
|
||||
reports
|
||||
|
||||
reset
|
||||
|
||||
rest
|
||||
|
||||
ring-tone
|
||||
|
||||
rotation
|
||||
|
||||
running-time
|
||||
|
||||
score
|
||||
|
||||
screenshot
|
||||
|
||||
scroll-image
|
||||
|
||||
send-number
|
||||
|
||||
servo-set-pulse
|
||||
|
||||
servo-write-pin
|
||||
|
||||
set-brightness
|
||||
|
||||
set-display-mode
|
||||
|
||||
set-group
|
||||
|
||||
set-pixel
|
||||
|
||||
set-tempo
|
||||
|
||||
show-animation
|
||||
|
||||
show-frame
|
||||
|
||||
show-image
|
||||
|
||||
show-leds
|
||||
|
||||
show-number
|
||||
|
||||
show-string
|
||||
|
||||
signal-strength
|
||||
|
||||
start-countdown
|
||||
|
||||
stop-animation
|
||||
|
||||
string
|
||||
|
||||
tell-camera-to
|
||||
|
||||
tell-microphone-to
|
||||
|
||||
tell-remote-control-to
|
||||
|
||||
temperature
|
||||
|
||||
tempo
|
||||
|
||||
toggle
|
||||
|
||||
toggle-all
|
||||
|
||||
touching
|
||||
|
||||
turn
|
||||
|
||||
unplot
|
||||
|
||||
var
|
||||
|
||||
while
|
||||
|
||||
width
|
||||
|
||||
write-line
|
||||
|
||||
write-value
|
11
docs/release-notes.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Release notes
|
||||
|
||||
```sim
|
||||
basic.forever(() => { basic.showString("RELEASE NOTES"); });
|
||||
```
|
||||
|
||||
### May 2017
|
||||
|
||||
We're happy to announce [m.pxt.io](https://m.pxt.io), an Blocks/JavaScript editor for the [BBC micro:bit](https://www.microbit.co.uk).
|
||||
|
||||
The editor is [open source](/open-source) on GitHub. Send us your PR!
|
BIN
docs/static/Microsoft-logo_rgb_c-gray.png
vendored
Normal file
After Width: | Height: | Size: 20 KiB |
1
docs/static/docslogo.svg
vendored
@ -1 +0,0 @@
|
||||
<svg xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' width='193.50101' height='32.755001' version='1.1'><g transform='translate(-1.3555,0.63251107)'><title>micro:bit logo</title><path d='m 38.7185,20.11349 c -1.677,0 -3.035,-1.364 -3.035,-3.042 0,-1.678 1.357,-3.038 3.035,-3.038 1.684,0 3.039,1.36 3.039,3.038 0,1.678 -1.355,3.042 -3.039,3.042 m -22.311,-6.077 c -1.677,0 -3.042,1.357 -3.042,3.035 0,1.678 1.363,3.042 3.042,3.042 1.674,0 3.036,-1.364 3.036,-3.042 0,-1.678 -1.363,-3.035 -3.036,-3.035 m -0.003,-5.99 22.576,0 c 4.979,0 9.027,4.047 9.027,9.027 0,4.979 -4.049,9.031 -9.027,9.031 l -22.576,0 c -4.977,0 -9.03,-4.053 -9.03,-9.031 -0.001,-4.98 4.053,-9.027 9.03,-9.027 m 22.576,24.076 c 8.299,0 15.047,-6.75 15.047,-15.049 0,-8.299 -6.748,-15.051 -15.047,-15.051 l -22.576,0 c -8.299,0 -15.049,6.752 -15.049,15.051 0,8.299 6.75,15.049 15.049,15.049 l 22.576,0 m 112.099,-21.953 c 0,-1.453 -1.195,-2.633 -2.662,-2.633 -1.455,0 -2.639,1.18 -2.639,2.633 0,1.471 1.184,2.672 2.639,2.672 1.466,0 2.662,-1.202 2.662,-2.672 z m -66.786,5.445 c 0,-4.764 -2.893,-8.093 -7.031,-8.093 -2.027,0 -3.814,0.851 -5.223,2.47 -1.467,-1.661 -3.152,-2.47 -5.127,-2.47 -4.162,0 -7.066,3.329 -7.066,8.093 l 0,10.466 3.812,0 0,-10.644 c 0,-2.416 1.336,-4.104 3.254,-4.104 1.617,0 3.25,1.409 3.25,4.104 l 0,10.645 3.848,0 0,-10.645 c 0,-2.416 1.338,-4.104 3.252,-4.104 1.863,0 3.217,1.727 3.217,4.104 l 0,10.645 3.814,0 0,-10.467 z m 6.953,-7.632 -3.846,0 0,18.099 3.846,0 0,-18.099 z m 0.569,-5.128 c 0,-1.377 -1.096,-2.454 -2.492,-2.454 -1.4,0 -2.453,1.054 -2.453,2.454 0,1.398 1.078,2.494 2.453,2.494 1.375,0 2.492,-1.117 2.492,-2.494 z m 18.328,20.914 0.576,-0.521 -2.828,-2.658 -0.488,0.455 c -1.252,1.149 -2.504,1.686 -3.945,1.686 -3.064,0 -5.557,-2.557 -5.557,-5.699 0,-3.121 2.492,-5.66 5.557,-5.66 1.432,0 2.646,0.521 3.949,1.693 l 0.512,0.46 2.748,-2.802 -0.49,-0.502 c -1.754,-1.793 -4.016,-2.696 -6.719,-2.696 -2.459,0 -4.869,1.022 -6.605,2.798 -1.738,1.734 -2.691,4.119 -2.691,6.709 0,2.596 0.953,4.979 2.684,6.705 1.771,1.811 4.117,2.811 6.615,2.811 2.401,-0.003 4.647,-0.937 6.682,-2.779 z m 7.25,-6.947 c 0,-3.322 1.145,-4.686 4.217,-5.029 l 0.641,-0.07 0,-3.797 -0.777,0.058 c -5.629,0.458 -8.143,3.247 -8.143,9.048 l 0,9.051 4.062,0 0,-9.261 0,0 z m 21.998,6.923 c 1.762,-1.756 2.729,-4.146 2.729,-6.715 0,-2.565 -0.967,-4.951 -2.723,-6.702 -1.77,-1.809 -4.105,-2.806 -6.576,-2.806 -2.492,0 -4.84,0.997 -6.613,2.806 -1.752,1.792 -2.721,4.174 -2.721,6.702 0,2.53 0.969,4.916 2.721,6.707 1.771,1.81 4.121,2.808 6.613,2.808 2.472,0 4.808,-0.998 6.57,-2.8 z m -1.229,-6.714 c 0,3.18 -2.361,5.665 -5.377,5.665 -2.945,0 -5.346,-2.541 -5.346,-5.665 0,-3.137 2.398,-5.695 5.346,-5.695 2.963,-0.002 5.377,2.558 5.377,5.695 z m 12.917,6.418 c 0,-1.468 -1.195,-2.667 -2.662,-2.667 -1.455,0 -2.639,1.199 -2.639,2.667 0,1.453 1.184,2.632 2.639,2.632 1.466,0 2.662,-1.179 2.662,-2.632 z m 19.507,0.296 c 1.76,-1.756 2.73,-4.146 2.73,-6.715 0,-2.528 -0.973,-4.911 -2.729,-6.702 -1.746,-1.787 -4.08,-2.77 -6.574,-2.77 -2.035,0 -3.84,0.572 -5.484,1.744 l 0,-9.934 -3.816,0 0.008,15.582 c -0.037,0.411 -0.037,0.821 -0.037,1.198 0,6.119 3.836,10.396 9.33,10.396 2.475,0.001 4.807,-0.997 6.572,-2.799 z m -1.013,-6.677 c 0,3.123 -2.494,5.66 -5.559,5.66 -3.115,0 -5.557,-2.484 -5.557,-5.66 0,-3.143 2.494,-5.698 5.557,-5.698 3.065,0 5.559,2.556 5.559,5.698 z m 10.881,-9.085 -3.846,0 0,18.099 3.846,0 0,-18.099 z m 0.572,-5.128 c 0,-1.377 -1.098,-2.454 -2.492,-2.454 -1.4,0 -2.457,1.054 -2.457,2.454 0,1.398 1.076,2.494 2.457,2.494 1.373,0 2.492,-1.117 2.492,-2.494 z m 13.83,19.759 -0.619,-0.089 c -2.855,-0.409 -4.133,-2.104 -4.133,-5.495 l 0,-5.126 4.752,0 0,-3.674 -4.752,0 0,-4.006 -3.887,0 0,4.006 -1.662,0 0,3.674 1.662,0 0,4.525 c 0,6.215 2.113,8.932 7.783,10.029 l 0.855,0.164 0,-4.008 0.001,0 z' style='fill:#ffffff' /></g></svg>
|
Before Width: | Height: | Size: 3.8 KiB |
BIN
docs/static/favicon.png
vendored
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 9.3 KiB |
1
docs/static/footerlogo.svg
vendored
@ -1 +0,0 @@
|
||||
<svg xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' width='193.50101' height='32.755001' version='1.1'><g transform='translate(-1.3555,0.63251107)'><title>micro:bit logo</title><path d='m 38.7185,20.11349 c -1.677,0 -3.035,-1.364 -3.035,-3.042 0,-1.678 1.357,-3.038 3.035,-3.038 1.684,0 3.039,1.36 3.039,3.038 0,1.678 -1.355,3.042 -3.039,3.042 m -22.311,-6.077 c -1.677,0 -3.042,1.357 -3.042,3.035 0,1.678 1.363,3.042 3.042,3.042 1.674,0 3.036,-1.364 3.036,-3.042 0,-1.678 -1.363,-3.035 -3.036,-3.035 m -0.003,-5.99 22.576,0 c 4.979,0 9.027,4.047 9.027,9.027 0,4.979 -4.049,9.031 -9.027,9.031 l -22.576,0 c -4.977,0 -9.03,-4.053 -9.03,-9.031 -0.001,-4.98 4.053,-9.027 9.03,-9.027 m 22.576,24.076 c 8.299,0 15.047,-6.75 15.047,-15.049 0,-8.299 -6.748,-15.051 -15.047,-15.051 l -22.576,0 c -8.299,0 -15.049,6.752 -15.049,15.051 0,8.299 6.75,15.049 15.049,15.049 l 22.576,0 m 112.099,-21.953 c 0,-1.453 -1.195,-2.633 -2.662,-2.633 -1.455,0 -2.639,1.18 -2.639,2.633 0,1.471 1.184,2.672 2.639,2.672 1.466,0 2.662,-1.202 2.662,-2.672 z m -66.786,5.445 c 0,-4.764 -2.893,-8.093 -7.031,-8.093 -2.027,0 -3.814,0.851 -5.223,2.47 -1.467,-1.661 -3.152,-2.47 -5.127,-2.47 -4.162,0 -7.066,3.329 -7.066,8.093 l 0,10.466 3.812,0 0,-10.644 c 0,-2.416 1.336,-4.104 3.254,-4.104 1.617,0 3.25,1.409 3.25,4.104 l 0,10.645 3.848,0 0,-10.645 c 0,-2.416 1.338,-4.104 3.252,-4.104 1.863,0 3.217,1.727 3.217,4.104 l 0,10.645 3.814,0 0,-10.467 z m 6.953,-7.632 -3.846,0 0,18.099 3.846,0 0,-18.099 z m 0.569,-5.128 c 0,-1.377 -1.096,-2.454 -2.492,-2.454 -1.4,0 -2.453,1.054 -2.453,2.454 0,1.398 1.078,2.494 2.453,2.494 1.375,0 2.492,-1.117 2.492,-2.494 z m 18.328,20.914 0.576,-0.521 -2.828,-2.658 -0.488,0.455 c -1.252,1.149 -2.504,1.686 -3.945,1.686 -3.064,0 -5.557,-2.557 -5.557,-5.699 0,-3.121 2.492,-5.66 5.557,-5.66 1.432,0 2.646,0.521 3.949,1.693 l 0.512,0.46 2.748,-2.802 -0.49,-0.502 c -1.754,-1.793 -4.016,-2.696 -6.719,-2.696 -2.459,0 -4.869,1.022 -6.605,2.798 -1.738,1.734 -2.691,4.119 -2.691,6.709 0,2.596 0.953,4.979 2.684,6.705 1.771,1.811 4.117,2.811 6.615,2.811 2.401,-0.003 4.647,-0.937 6.682,-2.779 z m 7.25,-6.947 c 0,-3.322 1.145,-4.686 4.217,-5.029 l 0.641,-0.07 0,-3.797 -0.777,0.058 c -5.629,0.458 -8.143,3.247 -8.143,9.048 l 0,9.051 4.062,0 0,-9.261 0,0 z m 21.998,6.923 c 1.762,-1.756 2.729,-4.146 2.729,-6.715 0,-2.565 -0.967,-4.951 -2.723,-6.702 -1.77,-1.809 -4.105,-2.806 -6.576,-2.806 -2.492,0 -4.84,0.997 -6.613,2.806 -1.752,1.792 -2.721,4.174 -2.721,6.702 0,2.53 0.969,4.916 2.721,6.707 1.771,1.81 4.121,2.808 6.613,2.808 2.472,0 4.808,-0.998 6.57,-2.8 z m -1.229,-6.714 c 0,3.18 -2.361,5.665 -5.377,5.665 -2.945,0 -5.346,-2.541 -5.346,-5.665 0,-3.137 2.398,-5.695 5.346,-5.695 2.963,-0.002 5.377,2.558 5.377,5.695 z m 12.917,6.418 c 0,-1.468 -1.195,-2.667 -2.662,-2.667 -1.455,0 -2.639,1.199 -2.639,2.667 0,1.453 1.184,2.632 2.639,2.632 1.466,0 2.662,-1.179 2.662,-2.632 z m 19.507,0.296 c 1.76,-1.756 2.73,-4.146 2.73,-6.715 0,-2.528 -0.973,-4.911 -2.729,-6.702 -1.746,-1.787 -4.08,-2.77 -6.574,-2.77 -2.035,0 -3.84,0.572 -5.484,1.744 l 0,-9.934 -3.816,0 0.008,15.582 c -0.037,0.411 -0.037,0.821 -0.037,1.198 0,6.119 3.836,10.396 9.33,10.396 2.475,0.001 4.807,-0.997 6.572,-2.799 z m -1.013,-6.677 c 0,3.123 -2.494,5.66 -5.559,5.66 -3.115,0 -5.557,-2.484 -5.557,-5.66 0,-3.143 2.494,-5.698 5.557,-5.698 3.065,0 5.559,2.556 5.559,5.698 z m 10.881,-9.085 -3.846,0 0,18.099 3.846,0 0,-18.099 z m 0.572,-5.128 c 0,-1.377 -1.098,-2.454 -2.492,-2.454 -1.4,0 -2.457,1.054 -2.457,2.454 0,1.398 1.076,2.494 2.457,2.494 1.373,0 2.492,-1.117 2.492,-2.494 z m 13.83,19.759 -0.619,-0.089 c -2.855,-0.409 -4.133,-2.104 -4.133,-5.495 l 0,-5.126 4.752,0 0,-3.674 -4.752,0 0,-4.006 -3.887,0 0,4.006 -1.662,0 0,3.674 1.662,0 0,4.525 c 0,6.215 2.113,8.932 7.783,10.029 l 0.855,0.164 0,-4.008 0.001,0 z' style='fill:#000000' /></g></svg>
|
Before Width: | Height: | Size: 3.8 KiB |
BIN
docs/static/icons/android-chrome-144x144.png
vendored
Normal file
After Width: | Height: | Size: 1011 B |
BIN
docs/static/icons/android-chrome-192x192.png
vendored
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
docs/static/icons/android-chrome-36x36.png
vendored
Normal file
After Width: | Height: | Size: 352 B |
BIN
docs/static/icons/android-chrome-48x48.png
vendored
Normal file
After Width: | Height: | Size: 450 B |
BIN
docs/static/icons/android-chrome-72x72.png
vendored
Normal file
After Width: | Height: | Size: 565 B |
BIN
docs/static/icons/android-chrome-96x96.png
vendored
Normal file
After Width: | Height: | Size: 724 B |
BIN
docs/static/icons/apple-touch-icon-114x114.png
vendored
Normal file
After Width: | Height: | Size: 757 B |
BIN
docs/static/icons/apple-touch-icon-120x120.png
vendored
Normal file
After Width: | Height: | Size: 752 B |
BIN
docs/static/icons/apple-touch-icon-144x144.png
vendored
Normal file
After Width: | Height: | Size: 917 B |
BIN
docs/static/icons/apple-touch-icon-152x152.png
vendored
Normal file
After Width: | Height: | Size: 958 B |
BIN
docs/static/icons/apple-touch-icon-180x180.png
vendored
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
docs/static/icons/apple-touch-icon-57x57.png
vendored
Normal file
After Width: | Height: | Size: 429 B |
BIN
docs/static/icons/apple-touch-icon-60x60.png
vendored
Normal file
After Width: | Height: | Size: 480 B |
BIN
docs/static/icons/apple-touch-icon-72x72.png
vendored
Normal file
After Width: | Height: | Size: 543 B |
BIN
docs/static/icons/apple-touch-icon-76x76.png
vendored
Normal file
After Width: | Height: | Size: 557 B |
BIN
docs/static/icons/apple-touch-icon-precomposed.png
vendored
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
docs/static/icons/apple-touch-icon.png
vendored
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
docs/static/icons/favicon-16x16.png
vendored
Normal file
After Width: | Height: | Size: 274 B |
BIN
docs/static/icons/favicon-32x32.png
vendored
Normal file
After Width: | Height: | Size: 382 B |
BIN
docs/static/icons/favicon-96x96.png
vendored
Normal file
After Width: | Height: | Size: 724 B |
BIN
docs/static/icons/mstile-144x144.png
vendored
Normal file
After Width: | Height: | Size: 1011 B |
BIN
docs/static/icons/mstile-150x150.png
vendored
Normal file
After Width: | Height: | Size: 918 B |