Compare commits
541 Commits
Author | SHA1 | Date | |
---|---|---|---|
566b750419 | |||
b119952e75 | |||
e4e6a5effd | |||
ec1117842d | |||
de4242bf71 | |||
59322fb06b | |||
19e609c245 | |||
a5cb663316 | |||
1dd0c1793e | |||
a4a74bdd6b | |||
45c82767d0 | |||
0c77927f35 | |||
672672e632 | |||
fe2ae855b0 | |||
6612080885 | |||
8641a81e05 | |||
656e183a1a | |||
1d56be507a | |||
6504007a65 | |||
fc0526e47c | |||
cb47a6a291 | |||
6f8060a8c7 | |||
4a8897c0a4 | |||
839a26e5a7 | |||
b46802804c | |||
34d1fac337 | |||
39c41f26b1 | |||
083a192a5b | |||
76cbad0cec | |||
ed84d49667 | |||
b9d867cf4e | |||
226dfa281a | |||
cc4f6c66da | |||
49ecac6332 | |||
638e1d3c53 | |||
712bc0ada4 | |||
8437f0cf3c | |||
9641c4b5ec | |||
e29216c709 | |||
06e255eeb9 | |||
91c70e9809 | |||
8014712994 | |||
a7d5804cea | |||
2e5984a65b | |||
c13bef01a4 | |||
16c08e4c9b | |||
444c37edcb | |||
51781be90b | |||
741eb4e4b4 | |||
350f595a52 | |||
06c392f16f | |||
4bf659c9ac | |||
db4711fd26 | |||
8275fefd08 | |||
8c474c899c | |||
48bb0e238a | |||
1d47b4de0d | |||
595e4a23e6 | |||
2d3ca71ffb | |||
3ba9d2867b | |||
ff7b229a3a | |||
f944af8122 | |||
35225468e4 | |||
72d5e83e5b | |||
436b56a2fa | |||
7a41730f82 | |||
372ddfa641 | |||
30078923a3 | |||
5ab9222200 | |||
8ae5a48f1e | |||
f9ed37d07b | |||
edfbc4da18 | |||
3a1c6a6ce3 | |||
9a4a2264fa | |||
e9558ce158 | |||
50677fadc4 | |||
649e8f7c0f | |||
0cb9c28f8d | |||
004d9b4315 | |||
7a5b3aba01 | |||
dc30263642 | |||
619658a057 | |||
472846bf3c | |||
ac4fbc850b | |||
c7054b7ee0 | |||
559a43e17b | |||
7671bc46ad | |||
b3c5f2926d | |||
28830aa905 | |||
7fbbb5e65a | |||
51ebc29887 | |||
f5d1722eae | |||
5f876d5ea9 | |||
31de8892fa | |||
0d0a68122d | |||
4ad660568e | |||
58e82a571d | |||
e629b866d5 | |||
f0ac2b7a05 | |||
e3c8db28e4 | |||
2c0e19a120 | |||
595eb788b2 | |||
2e15d22e9e | |||
57082654a9 | |||
8cbf7d38e3 | |||
a99a7325bf | |||
fa3ed9dd21 | |||
45fd40a553 | |||
5a18bea9eb | |||
d310312841 | |||
a4b93f7199 | |||
538a4b7bbf | |||
0078e7bc12 | |||
d2726133a9 | |||
00f4c9cbb3 | |||
e15da5dee1 | |||
85dda4ea84 | |||
a3ffe4e1cf | |||
90c4d4f73b | |||
6484d559d6 | |||
357436f14d | |||
85fe96b3fd | |||
cdac932c42 | |||
dcfc2a110d | |||
e9561f54c3 | |||
86f6b58d38 | |||
eee52a5c04 | |||
1a0b0eac71 | |||
5a98ae0bb8 | |||
a9eea9a618 | |||
3086c521e3 | |||
6788f79650 | |||
5900239045 | |||
248267ec2c | |||
9429075555 | |||
1fa871f2e7 | |||
04dab7df2c | |||
b6474467bc | |||
79ead74af4 | |||
0f8ff95b72 | |||
05028c4527 | |||
4054da3483 | |||
7052d27d6d | |||
365af8d672 | |||
5086ca308c | |||
c1af770afc | |||
e175e70d01 | |||
cbc228dca3 | |||
462127c661 | |||
487da05eca | |||
c938618d29 | |||
91321dab83 | |||
0cb3d6e44e | |||
7a98b06424 | |||
69c80d3aff | |||
1d82f08668 | |||
4681a68ffd | |||
0a69b773de | |||
3f66a1c16d | |||
d78781ad5a | |||
46281c3cd0 | |||
a58f67064f | |||
efe784441f | |||
05174f094a | |||
42773a1a0a | |||
32f96d09d4 | |||
05d88cb4ba | |||
7fe8dad1f6 | |||
858766ea3e | |||
81fe9afbb7 | |||
65c615f256 | |||
9c5c699fe7 | |||
dcede1703a | |||
5d33ab019d | |||
f7ec452ea0 | |||
20260e8933 | |||
d7704934e8 | |||
f1eafb0a6e | |||
27d6a8281a | |||
c5128aa497 | |||
a59394646c | |||
6851169dbe | |||
36b3486194 | |||
5d8ccd1d6d | |||
c713fe9bf4 | |||
f682e5e694 | |||
d2d776fd01 | |||
641a5e9673 | |||
93d90a2bde | |||
a54504f31c | |||
03111368e0 | |||
a973b2aec6 | |||
a7adf0e6c6 | |||
c10761128e | |||
9965f169b2 | |||
8bf755c15c | |||
d0b2a7db62 | |||
780192da3b | |||
07c1f08d18 | |||
25ac847266 | |||
63c8342b86 | |||
ea2bd7ba10 | |||
cec2d1e8af | |||
1b289b688b | |||
0cf91580cb | |||
392ebc8d07 | |||
9068aab12b | |||
85327a4e69 | |||
021260b3a4 | |||
4def93d7c5 | |||
9aca0c19fc | |||
3fcbdbdd82 | |||
4b7b6eebca | |||
2da0cf1178 | |||
141cb24e3d | |||
35483487af | |||
ec3a805326 | |||
780d8bcf8d | |||
f9a12cac64 | |||
03c2df3277 | |||
a7e98ccb3d | |||
1014d2f361 | |||
89f20a64d5 | |||
fae36a74af | |||
7e57c59b6f | |||
3141e12f4c | |||
4ebe9f595a | |||
50f0e85884 | |||
e28b5d48d4 | |||
562e96e09e | |||
6c5088f811 | |||
d5ccb7ad02 | |||
ade5176d21 | |||
d2f6d51c19 | |||
92b60a251d | |||
de9f2d7e67 | |||
4de5e3bd11 | |||
86a33e8f65 | |||
89010b6a8a | |||
48d4668a7a | |||
a2755dc4d2 | |||
52e67c6bfc | |||
5a6f23a7d0 | |||
d1b36f2022 | |||
284579181b | |||
20fcb05538 | |||
e1a2074ef5 | |||
fa3e33dab9 | |||
300a98b858 | |||
5986671bcb | |||
efd5c46143 | |||
62c1a1da35 | |||
ebbc7c983d | |||
173fc4bf7b | |||
47f1eadd27 | |||
8c06277a92 | |||
395f482f11 | |||
bbd21a84d6 | |||
fcf680e9bd | |||
8ac848c812 | |||
dd591af224 | |||
e5a7a81198 | |||
7a5228a5d0 | |||
fe5c8e520a | |||
96d354a8a8 | |||
02480b1c54 | |||
4fd321cccf | |||
4641c9456f | |||
498b5ec095 | |||
912be2ddfd | |||
6d7f8c5841 | |||
a782f4731a | |||
6e067bffd5 | |||
4a4007ba41 | |||
c9db08a2c6 | |||
5ec303b95c | |||
3d0523a298 | |||
3469ad6f8d | |||
d791738d84 | |||
355c341d36 | |||
1adb4a2bac | |||
03c0339e9a | |||
1649811015 | |||
14f16f9b2c | |||
66d3c6c7e8 | |||
7f27432222 | |||
870b26a85a | |||
aa6cb58dca | |||
6398a42dad | |||
cfc3eae77c | |||
438b745d32 | |||
21473f5b9b | |||
c85b6f9507 | |||
019b00209e | |||
6c11dbcdf4 | |||
91197c5cec | |||
9e5d9787c7 | |||
1c11a4823b | |||
d457c3e8d0 | |||
2ae21efb7b | |||
30211aa006 | |||
485a42758c | |||
0da5a5a349 | |||
efca68672a | |||
41ce2f66fa | |||
9393fc166e | |||
cfb4382941 | |||
aaca24ff5b | |||
0ce9be1a2b | |||
a88eb7fe02 | |||
06e4f7fb5c | |||
1b36485208 | |||
3b54cefa95 | |||
52857c9541 | |||
d10c2a20bd | |||
e2482cdf91 | |||
c045d87e4c | |||
34e23934b0 | |||
354196e01e | |||
bb2e8d0aef | |||
90f4e895d4 | |||
58c554caa6 | |||
6c688a7e59 | |||
71244065bb | |||
bbb1bc3dd7 | |||
806d0e2cff | |||
e0c4af1cae | |||
475821564e | |||
9d65dd605b | |||
67eec44411 | |||
280b555f86 | |||
2fcd32de0d | |||
78694e86a2 | |||
aeaa3d7bc1 | |||
af8ce3fccf | |||
47ef096b0f | |||
86c5c27b12 | |||
520c9217a5 | |||
4a34f2b932 | |||
034897b0a6 | |||
b504abc6da | |||
6dbfb9e96e | |||
d1021a30ca | |||
8d37be7cbe | |||
97066e1ba4 | |||
097564748c | |||
d873cbb6c3 | |||
adef3a6487 | |||
be0984cc4a | |||
f0947cddaa | |||
c5c5362b5d | |||
bcbbb1366a | |||
19fb5ecf01 | |||
0401aa60d2 | |||
e0c016fbf4 | |||
f046f0e50c | |||
90f48ac77a | |||
23f83df6df | |||
98e4f80399 | |||
b1fcc51bc8 | |||
63e24ce90a | |||
63d0b86508 | |||
672f3b94ca | |||
f0b91b07c1 | |||
2923d045b1 | |||
3cf36b4549 | |||
a42aa553e6 | |||
b12598e421 | |||
9a85075456 | |||
ce7b630870 | |||
9ac308da92 | |||
6315ca90e5 | |||
ecfe0a7f16 | |||
f701bca23f | |||
7313c76e8b | |||
77003b30f2 | |||
274bb9e042 | |||
e316f068e2 | |||
c75e77593a | |||
ecbf8409ea | |||
411fe52813 | |||
0d04376413 | |||
5deffe832c | |||
528f696b8c | |||
dfb5f7dd11 | |||
a4fb934a18 | |||
59b11ec2a9 | |||
d961e14e5c | |||
83c8c07b94 | |||
152f84cd79 | |||
ef58b54fdb | |||
50e2f3fa94 | |||
14f4e6092a | |||
f7a005c656 | |||
7e19fbb3ca | |||
e706809037 | |||
5d6bc2f5df | |||
22433317b9 | |||
fabf09477c | |||
f9e0fe1b8d | |||
c49fb27d4c | |||
24b20543c5 | |||
be97665ea2 | |||
657cdeb53e | |||
08575d352b | |||
c9ba7af3f3 | |||
917072a336 | |||
fd5357b273 | |||
3a8bbfbd91 | |||
0b457d6a50 | |||
4f960f5585 | |||
5e62d5c30d | |||
4aa2d129e9 | |||
09f4001c7a | |||
eae2f0436d | |||
287c9da3bd | |||
056ec1bc96 | |||
16439bfca3 | |||
7117ba771e | |||
633522c800 | |||
3f94033c7d | |||
1bc00f476c | |||
0269ffa5ae | |||
c64225982e | |||
29eef560b0 | |||
90e191c4ca | |||
efd310f0b4 | |||
0a5c2e4df9 | |||
1d6eaf0370 | |||
b4b789422e | |||
cf982d7c52 | |||
2dafe5d253 | |||
63422bf696 | |||
56dc8571b7 | |||
d9190369b7 | |||
ea4bc7f4e8 | |||
7aa136d01c | |||
4eeae7e239 | |||
11b6ba0862 | |||
349a385f97 | |||
48afb52ef1 | |||
e5dc046fcc | |||
7f7aa1c60b | |||
584aaf8c6d | |||
029b5cda2b | |||
ed2f6d05ad | |||
26e20d75a4 | |||
31f5db32d1 | |||
107fe2aefa | |||
171f578b0b | |||
90756557f2 | |||
1e89d142ec | |||
002f08ca37 | |||
054501ace0 | |||
980fbc9c1e | |||
dab48cf42d | |||
652abe0892 | |||
781472e7ce | |||
1e4197b4fa | |||
8ec20b87d7 | |||
3a6e132c7f | |||
41c7e88928 | |||
19f757e159 | |||
fb222fd732 | |||
937bcc61ad | |||
7d61e5fe7c | |||
773dae8fc8 | |||
511f399d90 | |||
633ce491af | |||
8193c4790f | |||
21e64d01e3 | |||
641d8fcb9b | |||
84736554b9 | |||
e2c7579dd4 | |||
e0cf776591 | |||
da38ca2234 | |||
682ae92a08 | |||
f5f36d9cca | |||
19775e307a | |||
89406330cf | |||
9bc1e38345 | |||
85d5073fbb | |||
d76d92e041 | |||
6799721c9b | |||
16cf45aa7c | |||
4963bf776a | |||
237c5c019b | |||
cf37baa337 | |||
7303a1235f | |||
38ee5efdd4 | |||
474d5bb762 | |||
f045942297 | |||
7936517a03 | |||
ee60396e35 | |||
307d25ce7d | |||
ec48474231 | |||
524bcee5ed | |||
83cfd5738f | |||
83b8ba1102 | |||
2169cb044c | |||
76adc3c00a | |||
c6e38bd7a9 | |||
c60a4cb359 | |||
298382c19f | |||
ef849b645b | |||
78e8c9f176 | |||
57aadd0b27 | |||
e60c163b08 | |||
95e4c609a4 | |||
f2e1bc0168 | |||
5c818980ed | |||
172aa6a4d7 | |||
c5b9d0876a | |||
4716d06fe6 | |||
a2aaed2923 | |||
38aa6439a2 | |||
f078d59bb5 | |||
dffbe5dcb4 | |||
d0821710f6 | |||
2291f8b899 | |||
2bc5db517e | |||
f191d9033d | |||
7d912110f4 | |||
ae882a0107 | |||
367e80cb77 | |||
c3865afe8c | |||
6b9b636ae6 | |||
9a20841c6e | |||
9e95f1a442 | |||
c6ce36065e | |||
27f28032fb | |||
2dc9cffa99 | |||
376512f704 | |||
3813fba899 | |||
84816f4f39 | |||
2b095dfe21 | |||
2e3cdee2a2 | |||
ec404e5887 | |||
ba69563bf4 | |||
cc6594921f | |||
bf1269b82e |
2
.gitignore
vendored
2
.gitignore
vendored
@ -15,7 +15,7 @@ clients/win10/app/bld
|
||||
clients/win10/*.opendb
|
||||
clients/**/bin/**
|
||||
clients/**/obj/**
|
||||
clients/electron/projects
|
||||
electron-out
|
||||
hexcache
|
||||
|
||||
*.user
|
||||
|
@ -8,7 +8,6 @@ script:
|
||||
- "(cd libs/lang-test0; node ../../node_modules/pxt-core/built/pxt.js test)"
|
||||
- "(cd libs/lang-test1; node ../../node_modules/pxt-core/built/pxt.js test)"
|
||||
- "node node_modules/pxt-core/built/pxt.js testdir tests"
|
||||
- "node node_modules/pxt-core/built/pxt.js uploaddoc"
|
||||
- "(cd libs/hello; node ../../node_modules/pxt-core/built/pxt.js testconv https://az851932.vo.msecnd.net/files/td-converter-tests-v1.json)"
|
||||
sudo: false
|
||||
notifications:
|
||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -1,6 +1,6 @@
|
||||
// Place your settings in this file to overwrite default and user settings.
|
||||
{
|
||||
"file.autoSave": "afterDelay",
|
||||
"files.autoSave": "afterDelay",
|
||||
"files.watcherExclude": {
|
||||
"**/.git/objects/**": true,
|
||||
"**/built/**": true,
|
||||
|
26
CONTRIBUTING.md
Normal file
26
CONTRIBUTING.md
Normal file
@ -0,0 +1,26 @@
|
||||
# Contributing Code
|
||||
|
||||
PXT accepts bug fix pull requests. For a bug fix PR to be accepted, it must first have a tracking issue that has been marked approved. Your PR should link to the bug you are fixing. If you've submitted a PR for a bug, please post a comment in the bug to avoid duplication of effort.
|
||||
|
||||
PXT also accepts new feature pull requests. For a feature-level PR to be accepted, it first needs to have design discussion. Design discussion can take one of two forms a) a feature request in the issue tracker that has been marked as approved or b) the PR must be accompanied by a full design spec and this spec is later approved in the open design discussion. Features are evaluated against their complexity, impact on other features, roadmap alignment, and maintainability.
|
||||
|
||||
These two blogs posts on contributing code to open source projects are a good reference: [Open Source Contribution Etiquette](http://tirania.org/blog/archive/2010/Dec-31.html) by Miguel de Icaza and [Don't "Push" Your Pull Requests](https://www.igvita.com/2011/12/19/dont-push-your-pull-requests/) by Ilya Grigorik.
|
||||
|
||||
## Security
|
||||
|
||||
If you believe you have found a security issue in PXT, please share it with us privately following the guidance at the Microsoft [Security TechCenter](https://technet.microsoft.com/en-us/security/ff852094). Reporting it via this channel helps minimize risk to projects built with PXT.
|
||||
|
||||
## Legal
|
||||
|
||||
You will need to complete a Contributor License Agreement (CLA) before your pull request can be accepted. This agreement testifies that you are granting us permission to use the source code you are submitting, and that this work is being submitted under appropriate license that we can use it.
|
||||
|
||||
You can complete the CLA by going through the steps at https://cla.microsoft.com. Once we have received the signed CLA, we'll review the request. You will only need to do this once.
|
||||
|
||||
## Housekeeping
|
||||
|
||||
Your pull request should:
|
||||
* Include a description of what your change intends to do
|
||||
* Be a child commit of a reasonably recent commit in the master branch
|
||||
* Pass all unit tests
|
||||
* Have a clear commit message
|
||||
* Include adequate tests
|
25
LICENSE.txt
Normal file
25
LICENSE.txt
Normal file
@ -0,0 +1,25 @@
|
||||
PXT - Programming Experience Toolkit
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -7,6 +7,10 @@ PXT ([Microsoft Programming Experience Toolkit](https://github.com/Microsoft/pxt
|
||||
|
||||
[](https://travis-ci.org/Microsoft/pxt-microbit)
|
||||
|
||||
## Issue tracking
|
||||
|
||||
All issue tracking for this repo happens at https://github.com/Microsoft/pxt, see you there!
|
||||
|
||||
## Local server
|
||||
|
||||
The local server allows to run the editor and the documentation from your computer.
|
||||
@ -15,7 +19,7 @@ The local server allows to run the editor and the documentation from your comput
|
||||
|
||||
The following commands are a 1-time setup after synching the repo on your machine.
|
||||
|
||||
* if not yet installed, install [Node.js 4.4.5 or higher](https://nodejs.org/en/download/)
|
||||
* See requirements for [pxt](https://github.com/Microsoft/pxt)
|
||||
* [clone this repo](https://help.github.com/articles/cloning-a-repository/) to your computer and go in the project folder
|
||||
```
|
||||
git clone https://github.com/microsoft/pxt-microbit
|
||||
|
43
THIRD-PARTY-NOTICES.txt
Normal file
43
THIRD-PARTY-NOTICES.txt
Normal file
@ -0,0 +1,43 @@
|
||||
/*!----------------- PXT ThirdPartyNotices -------------------------------------------------------
|
||||
|
||||
PXT uses third party material from the projects listed below.
|
||||
The original copyright notice and the license under which Microsoft
|
||||
received such third party material are set forth below. Microsoft
|
||||
reserves all other rights not expressly granted, whether by
|
||||
implication, estoppel or otherwise.
|
||||
|
||||
In the event that we accidentally failed to list a required notice, please
|
||||
bring it to our attention. Post an issue or email us:
|
||||
|
||||
abchatra@microsoft.com
|
||||
|
||||
---------------------------------------------
|
||||
Third Party Code Components
|
||||
---------------------------------------------
|
||||
|
||||
Some code derived (as noted) from
|
||||
|
||||
https://github.com/bbcmicrobit/micropython
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2016 The MicroPython-on-micro:bit Developers, as listed
|
||||
in the accompanying AUTHORS file
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
@ -1,5 +1,5 @@
|
||||
# microbit-chrome
|
||||
Prototype chrome addon that exposes the micro:bit's serial output to webpages.
|
||||
Prototype chrome addon that exposes the @boardname@'s serial output to webpages.
|
||||
* watch the [demo video](https://vimeo.com/146207766)
|
||||
|
||||
# Installation
|
||||
|
@ -1,4 +1,3 @@
|
||||
///<reference path='typings/browser.d.ts'/>
|
||||
var connections = [];
|
||||
// A list of "ports", i.e. connected clients (such as web pages). Multiple web
|
||||
// pages can connect to our service: they all receive the same data.
|
||||
@ -41,7 +40,7 @@ function findNewDevices() {
|
||||
function main() {
|
||||
// Register new clients in the [ports] global variable.
|
||||
chrome.runtime.onConnectExternal.addListener(function (port) {
|
||||
if (/^(micro:bit|touchdevelop|yelm|pxt|codemicrobit|codethemicrobit)$/.test(port.name)) {
|
||||
if (/^(micro:bit|touchdevelop|yelm|pxt|codemicrobit|codethemicrobit|pxt.microbit.org)$/.test(port.name)) {
|
||||
ports.push(port);
|
||||
port.onDisconnect.addListener(function () {
|
||||
ports = ports.filter(function (x) { return x != port; });
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 2.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.6 KiB |
@ -6,10 +6,10 @@
|
||||
},
|
||||
|
||||
"manifest_version": 2,
|
||||
"name": "code the micro:bit",
|
||||
"version": "0.6.0",
|
||||
"name": "pxt.microbit.org",
|
||||
"version": "0.7.0",
|
||||
"author": "Microsoft Corporation",
|
||||
"short_name": "code the micro:bit",
|
||||
"short_name": "pxt.microbit.org",
|
||||
|
||||
"description": "Extension for https://pxt.microbit.org.",
|
||||
"homepage_url": "https://pxt.microbit.org",
|
||||
|
2
clients/electron/.gitignore
vendored
2
clients/electron/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
node_modules
|
||||
projects
|
@ -1,5 +0,0 @@
|
||||
# PXT micro:bit Electron app
|
||||
|
||||
A very basic wrapper around the web app. To install, copy the contents of this
|
||||
directory to somewhere outside the main `pxt-microbit` repository. Then run `npm
|
||||
install && npm start`.
|
@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>code the micro:bit</title>
|
||||
</head>
|
||||
<body>
|
||||
<webview id="webview" style="position:absolute; left:0; top:0; right:0; bottom:0"/>
|
||||
<script>
|
||||
const webview = document.getElementById("webview")
|
||||
const url = `http://localhost:3232/${window.location.hash}`
|
||||
webview.src = url
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,39 +0,0 @@
|
||||
const {app, BrowserWindow, Menu} = require('electron')
|
||||
const pxt = require('pxt-core')
|
||||
const path = require('path')
|
||||
|
||||
let win
|
||||
|
||||
const cliPath = path.join(process.cwd(), "node_modules/pxt-microbit")
|
||||
|
||||
function startServerAndCreateWindow() {
|
||||
pxt.mainCli(cliPath, ["serve", "-no-browser"])
|
||||
createWindow()
|
||||
}
|
||||
|
||||
function createWindow () {
|
||||
win = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
title: "code the micro:bit"
|
||||
})
|
||||
Menu.setApplicationMenu(null)
|
||||
win.loadURL(`file://${__dirname}/index.html#local_token=${pxt.globalConfig.localToken}`)
|
||||
win.on('closed', () => {
|
||||
win = null
|
||||
})
|
||||
}
|
||||
|
||||
app.on('ready', startServerAndCreateWindow)
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('activate', () => {
|
||||
if (win === null) {
|
||||
createWindow()
|
||||
}
|
||||
})
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"name" : "code-the-microbit",
|
||||
"version" : "1.0.0",
|
||||
"description": "Blocks / Javascript editor",
|
||||
"author": "Microsoft",
|
||||
"main" : "main.js",
|
||||
"scripts": {
|
||||
"start": "node_modules/.bin/electron ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "*",
|
||||
"pxt-microbit": "*"
|
||||
}
|
||||
}
|
59
cmds/cmds.ts
59
cmds/cmds.ts
@ -1,59 +0,0 @@
|
||||
/// <reference path="../node_modules/pxt-core/built/pxt.d.ts"/>
|
||||
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import * as child_process from "child_process";
|
||||
|
||||
let writeFileAsync: any = Promise.promisify(fs.writeFile)
|
||||
let execAsync: (cmd: string, options?: { cwd?: string }) => Promise<Buffer> = Promise.promisify(child_process.exec)
|
||||
let readDirAsync = Promise.promisify(fs.readdir)
|
||||
|
||||
|
||||
export function deployCoreAsync(res: ts.pxtc.CompileResult) {
|
||||
return getBitDrivesAsync()
|
||||
.then(drives => {
|
||||
if (drives.length == 0) {
|
||||
console.log("cannot find any drives to deploy to");
|
||||
return Promise.resolve(0);
|
||||
}
|
||||
|
||||
console.log(`copy ${ts.pxtc.BINARY_HEX} to ` + drives.join(", "));
|
||||
|
||||
let writeHexFile = (filename: string) => {
|
||||
return writeFileAsync(filename + ts.pxtc.BINARY_HEX, res.outfiles[ts.pxtc.BINARY_HEX])
|
||||
.then(() => console.log("wrote hex file to " + filename));
|
||||
};
|
||||
|
||||
return Promise.map(drives, d => writeHexFile(d))
|
||||
.then(() => drives.length);
|
||||
});
|
||||
}
|
||||
|
||||
function getBitDrivesAsync(): Promise<string[]> {
|
||||
if (process.platform == "win32") {
|
||||
const rx = new RegExp("^([A-Z]:).* " + pxt.appTarget.compile.deployDrives)
|
||||
return execAsync("wmic PATH Win32_LogicalDisk get DeviceID, VolumeName, FileSystem")
|
||||
.then(buf => {
|
||||
let res: string[] = []
|
||||
buf.toString("utf8").split(/\n/).forEach(ln => {
|
||||
let m = rx.exec(ln)
|
||||
if (m) {
|
||||
res.push(m[1] + "/")
|
||||
}
|
||||
})
|
||||
return res
|
||||
})
|
||||
}
|
||||
else if (process.platform == "darwin") {
|
||||
const rx = new RegExp(pxt.appTarget.compile.deployDrives)
|
||||
return readDirAsync("/Volumes")
|
||||
.then(lst => lst.filter(s => rx.test(s)).map(s => "/Volumes/" + s + "/"))
|
||||
} else if (process.platform == "linux") {
|
||||
const rx = new RegExp(pxt.appTarget.compile.deployDrives)
|
||||
const user = process.env["USER"]
|
||||
return readDirAsync(`/media/${user}`)
|
||||
.then(lst => lst.filter(s => rx.test(s)).map(s => `/media/${user}/${s}/`))
|
||||
} else {
|
||||
return Promise.resolve([])
|
||||
}
|
||||
}
|
7
cmds/pxtrequire.ts
Normal file
7
cmds/pxtrequire.ts
Normal file
@ -0,0 +1,7 @@
|
||||
/// <reference path="../node_modules/pxt-core/typings/globals/node/index.d.ts"/>
|
||||
/// <reference path="../node_modules/pxt-core/built/pxtlib.d.ts" />
|
||||
|
||||
import * as path from "path";
|
||||
export let pxtCore = require("pxt-core");
|
||||
// require.resolve() gives path to [pxt dir]/built/pxt.js, so move up twice to get pxt root dir
|
||||
export let pxtCoreDir = path.resolve(require.resolve("pxt-core"), "..", "..");
|
@ -1,16 +0,0 @@
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta name="twitter:site" content="@codethemicrobit" />
|
||||
<meta name="twitter:title" content="code the micro:bit" />
|
||||
<meta name="twitter:description" content="Blocks+JavaScript for programming your micro:bit" />
|
||||
<meta name="twitter:image" content="https://az851932.vo.msecnd.net/pub/drbwxcth" />
|
||||
|
||||
<meta property="og:title" content="micro:bit editor" />
|
||||
<meta property="og:description" content="Blocks+JavaScript for programming your micro:bit" />
|
||||
<meta property="og:site_name" content="code the micro:bit" />
|
||||
<meta property="og:image" content="https://az851932.vo.msecnd.net/pub/drbwxcth" />
|
||||
<!--
|
||||
Canonical URL needs to wait until main release is updated.
|
||||
<meta property="og:url" content="https://codethemicrobit.com" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="fb:app_id" content="" />
|
||||
-->
|
@ -1,21 +0,0 @@
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta name="twitter:site" content="@codethemicrobit" />
|
||||
<meta name="twitter:title" content="@name@" />
|
||||
<meta name="twitter:description" content="@description@" />
|
||||
<meta name="twitter:image" content="@cardLogo@" />
|
||||
|
||||
<meta property="og:title" content="@name@" />
|
||||
<meta property="og:site_name" content="code the micro:bit" />
|
||||
<meta property="og:description" content="@description@" />
|
||||
<meta property="og:image" content="@cardLogo@" />
|
||||
<!--
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="fb:app_id" content="" />
|
||||
-->
|
||||
|
||||
<link rel="apple-touch-icon" href="@appLogo@">
|
||||
<link rel="icon" type="image/png" href="@appLogo@">
|
||||
<link rel="mask-icon" href="https://az851932.vo.msecnd.net/pub/zwxazere/safari-pinned-tab.svg" color="#000000">
|
||||
<link rel="shortcut icon" href="@appLogo@">
|
||||
<meta name="theme-color" content="@accentColor@">
|
||||
|
@ -1,5 +0,0 @@
|
||||
#root .avatar .avatar-image {
|
||||
background-image: url(https://az851932.vo.msecnd.net/pub/jovrytni/microbit.simplified.svg);
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
# Dokumentacja
|
||||
|
||||
Witamy na stronach dokumentacji!
|
||||
|
||||
* Przeglądnij [instrukcje obsługi](/reference)
|
||||
* Dowiedz się więcej o [urządzeniu](/device)
|
||||
* Wystartuj z [lekcjami](/lessons)
|
@ -1,6 +1,10 @@
|
||||
# Blocks language
|
||||
|
||||
### @description Langugage constructs for the Block editor.
|
||||
### @description Language constructs for the Block editor.
|
||||
|
||||
Blocks snap into each other to define the program that your @boardname@ will run.
|
||||
Blocks can be event (buttons, shake, ...) or need to be snapped into an event to run.
|
||||
The [on-start](/blocks/on-start) event runs first.
|
||||
|
||||
```namespaces
|
||||
for (let i = 0;i<5;++i) {}
|
||||
@ -11,4 +15,4 @@ Math.random(5);
|
||||
|
||||
## See Also
|
||||
|
||||
[logic](/blocks/logic), [loops](/blocks/loops), [math](/blocks/math), [variables](/blocks/variables)
|
||||
[logic](/blocks/logic), [loops](/blocks/loops), [math](/blocks/math), [variables](/blocks/variables), [on-start](/blocks/on-start)
|
@ -86,12 +86,14 @@ if (led.point(1,1) && led.point(2,2)) {
|
||||
When you compare two Numbers, you get a Boolean value, such as the comparison `x < 5` in the code below:
|
||||
|
||||
```blocks
|
||||
let x = Math.random(5)
|
||||
if(x < 5) {
|
||||
basic.showString("low");
|
||||
} else {
|
||||
basic.showString("high");
|
||||
}
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
let x = Math.random(5)
|
||||
if(x < 5) {
|
||||
basic.showString("low");
|
||||
} else {
|
||||
basic.showString("high");
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
See the documentation on [Numbers](/reference/types/number) for more information on comparing two Numbers. You can also [compare strings](/reference/types/string-functions) using the `equals` function.
|
||||
|
@ -14,13 +14,15 @@ Click on the dark blue gear icon (see above) to add an *else* or *if* to the cur
|
||||
|
||||
### Example: adjusting screen brightness
|
||||
|
||||
```blocks
|
||||
if(input.lightLevel()<100){
|
||||
led.setBrightness(255);
|
||||
}
|
||||
```
|
||||
If the [light level](/reference/input/light-level) is `< 100`, this code sets the brightness to `255` when the button A is pressed:
|
||||
|
||||
If the [light level](/reference/input/light-level) is `< 100`, this code sets the brightness to `255`:
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
if(input.lightLevel()<100){
|
||||
led.setBrightness(255);
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
|
@ -4,14 +4,21 @@
|
||||
|
||||
Run part of the program the number of times you say.
|
||||
|
||||
```block
|
||||
for(let i = 0; i <= 4; ++i) {
|
||||
}
|
||||
```
|
||||
|
||||
### Example: Count to 4
|
||||
|
||||
This program will show the numbers 0, 1, 2, 3, and 4 one after another on the LED screen.
|
||||
|
||||
```blocks
|
||||
for(let i = 0; i < 5; ++i) {
|
||||
basic.showNumber(i)
|
||||
}
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
for(let i = 0; i < 5; ++i) {
|
||||
basic.showNumber(i)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### See also
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
Repeat code while a [Boolean](/blocks/logic/boolean) `condition` is true.
|
||||
|
||||
```blocks
|
||||
```block
|
||||
while(true) {
|
||||
}
|
||||
```
|
||||
@ -16,11 +16,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`).
|
||||
|
||||
```blocks
|
||||
let index = 4;
|
||||
while(index >= 0) {
|
||||
led.plot(index, index);
|
||||
index--;
|
||||
}
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
let index = 4;
|
||||
while(index >= 0) {
|
||||
led.plot(index, index);
|
||||
index--;
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### See also
|
||||
|
28
docs/blocks/on-start.md
Normal file
28
docs/blocks/on-start.md
Normal file
@ -0,0 +1,28 @@
|
||||
# On Start
|
||||
|
||||
An event that runs when the program starts.
|
||||
|
||||
The ``on start`` is a special event that runs when the program starts, before any other event.
|
||||
Use this event to initialize your program.
|
||||
|
||||
## Example
|
||||
|
||||
In this example, ``on start`` sets a dimmer brightness on the screen and the button handler shows a string.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showString("Hello!")
|
||||
})
|
||||
led.setBrightness(50)
|
||||
```
|
||||
|
||||
## What about JavaScript?
|
||||
|
||||
``on-start`` only exists in the block editor. In JavaScript, all code executes sequentially from the first line.
|
||||
|
||||
## Hey, my events moved!
|
||||
|
||||
When we transform the blocks into JavaScript, we always place all the event registrations (buttons, shake, ...)
|
||||
before launching the ``on start`` code.
|
||||
|
||||
If a block from ``on start`` pauses, other registered events will have the opportunity to run as well.
|
@ -1,7 +1,6 @@
|
||||
# Unsupported configuration
|
||||
|
||||
[pxt.microbit.org](https://pxt.microbit.org) doesn't currently support
|
||||
your browser or operating system. The following configurations are supported:
|
||||
Your browser is currently not supported. The following configurations are supported:
|
||||
|
||||
## Windows
|
||||
|
||||
|
@ -91,3 +91,10 @@ basic.showString("d", 150)
|
||||
|
||||
You will not see the LED at position `0,0` lit up because the `show string` function overwrites the whole display buffer.
|
||||
|
||||
|
||||
### Pins: P3, P4, P6, P7, P9, P10
|
||||
|
||||
These pins are coupled to the LED matrix display, and also it’s associated ambient light sensing mode.
|
||||
To disable the display driver feature (which will automatically disable the light sensing feature) use the function [led.enable](/reference/led/enable).
|
||||
|
||||
More information at http://tech.microbit.org/hardware/edgeconnector_ds/ .
|
||||
|
116
docs/device/servo.md
Normal file
116
docs/device/servo.md
Normal file
@ -0,0 +1,116 @@
|
||||
# Equipping a microservo with Crocodile clips
|
||||
|
||||
## Materials
|
||||
* Cutting pliers or wire cutter
|
||||
* Tape (masking, duct tape, and/or packing tape)
|
||||
* 3 crocodile clips, yellow, red and black.
|
||||
* 1 micro servo 9g (SG90)
|
||||
|
||||
## Using a microservo with the @boardname@
|
||||
|
||||
The @boardname@ provides just enough current to operate the SG90 microservo.
|
||||
The servo requires 3 connections: GND, 3V and a logic pin.
|
||||
In this tutorial, we will equip the servo with crocodile clips to make it easier to use.
|
||||
However, you could also use a shield or female to crocodile clips to acheive the same effect.
|
||||
|
||||
If you are running a class or activity, you should consider preparing all servos before hand.
|
||||
|
||||
### ~ hint
|
||||
|
||||
Kitronik wrote an excellent in-depth guide about using servos with the @boardname@.
|
||||
Check it out at https://www.kitronik.co.uk/blog/using-bbc-microbit-control-servo/ .
|
||||
|
||||
### ~
|
||||
|
||||
## Step 1: cutout the connector
|
||||
|
||||
Using the cutting pliers, cut out the dark plastic connector.
|
||||
|
||||

|
||||
|
||||
## Step 2: strip out cables
|
||||
|
||||
Using the plier or a wire stripper, strip the plastic from the cables.
|
||||
|
||||

|
||||
|
||||
## Step 3: threading the servo cablers
|
||||
|
||||
Thread the servo cables.
|
||||
|
||||

|
||||
|
||||
## Step 4: crocobile clip claps
|
||||
|
||||
Cut a crocodile cable in two and strip out the casing.
|
||||
If possible try to use the same cable colors as the servo!
|
||||
|
||||

|
||||
|
||||
## Step 5: thread cables together
|
||||
|
||||
Place the cables next to each other
|
||||
|
||||

|
||||
|
||||
... and thread them together.
|
||||
|
||||

|
||||
|
||||
### ~ hint
|
||||
|
||||
It is very **important** to ensure that there is a good connection between the 2 cables.
|
||||
If the connection is weak, the microservo will not receive enough current and it will not work.
|
||||
**If you have access to a soldering iron, we strongly recommend to solder this connection.**
|
||||
|
||||
### ~
|
||||
|
||||
## Step 4: protect the connection
|
||||
|
||||
Protect the connection with electrical or duct tape.
|
||||
|
||||

|
||||
|
||||
## Step 5: repeat for all cables
|
||||
|
||||
Repeat the same process until all cables are connected.
|
||||
|
||||

|
||||
|
||||
## Step 6: testing!
|
||||
|
||||
It's time to test that your connection are all proper and that the servo will function **when the @boardname@ is powered by battery**.
|
||||
|
||||
* Connect the microservo to the @boardname@. Black cable on ``GND``, red cable on ``3V`` and remaining cable on ``P0``.
|
||||
|
||||

|
||||
|
||||
### ~ hint
|
||||
|
||||
When attaching the crocodile clips to the pins, don't hesitate to grab the side of the board with the jaws.
|
||||
|
||||

|
||||
|
||||
### ~
|
||||
|
||||
* Download the following code to your @boardname@
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
pins.servoWritePin(AnalogPin.P0, pins.map(
|
||||
input.acceleration(Dimension.X),
|
||||
-512,
|
||||
512,
|
||||
0,
|
||||
180
|
||||
))
|
||||
})
|
||||
```
|
||||
|
||||
* When powered by USB, make sure that the servo moves when you tilt the board.
|
||||
* When powered by batteries **only**, make sure that the servo moves when you tilt the board.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If your servo seems to sutter and stay stuck at a particular position, it means that it is not receiving enough power.
|
||||
This is probably due to a weak connection or low battery level. Check each connection and check your batteries.
|
@ -6,12 +6,13 @@
|
||||
|
||||
* **[Getting Started](/getting-started)**
|
||||
* [Projects](/projects)
|
||||
* [Examples](/examples)
|
||||
* [Lessons](/lessons)
|
||||
|
||||
### Micro:bit reference
|
||||
### @boardname@ reference
|
||||
|
||||
* [The micro:bit APIs](/reference)
|
||||
* [The micro:bit device](/device)
|
||||
* [The @boardname@ APIs](/reference)
|
||||
* [The @boardname@ device](/device)
|
||||
|
||||
### Language and data reference
|
||||
|
||||
@ -28,4 +29,4 @@
|
||||
|
||||
* [Command Line Interface](/cli)
|
||||
* Learn about [packages](/packages)
|
||||
* [Release notes](/release-notes)
|
||||
|
||||
|
35
docs/examples.md
Normal file
35
docs/examples.md
Normal file
@ -0,0 +1,35 @@
|
||||
# Examples
|
||||
|
||||
Here are some fun programs for your @boardname@!
|
||||
|
||||
## Fun stuff
|
||||
|
||||
```codecard
|
||||
[{
|
||||
"name": "Blinky",
|
||||
"url":"/examples/blinky"
|
||||
},
|
||||
{
|
||||
"name": "Name Tag",
|
||||
"url":"/examples/name-tag"
|
||||
},
|
||||
{
|
||||
"name": "Rando",
|
||||
"url":"/examples/rando"
|
||||
}]
|
||||
```
|
||||
|
||||
## Sensors
|
||||
|
||||
```codecard
|
||||
[{
|
||||
"name": "Plot Acceleration",
|
||||
"url":"/examples/plot-acceleration"
|
||||
}, {
|
||||
"name": "Plot Light Level",
|
||||
"url":"/examples/plot-light-level"
|
||||
}, {
|
||||
"name": "Plot Analog Pin",
|
||||
"url":"/examples/plot-analog-pin"
|
||||
}]
|
||||
```
|
20
docs/examples/blinky.md
Normal file
20
docs/examples/blinky.md
Normal file
@ -0,0 +1,20 @@
|
||||
# Blinky
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .`
|
||||
);
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .`
|
||||
);
|
||||
})
|
||||
```
|
7
docs/examples/name-tag.md
Normal file
7
docs/examples/name-tag.md
Normal file
@ -0,0 +1,7 @@
|
||||
# Name Tag
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
basic.showString("JAMES")
|
||||
})
|
||||
```
|
10
docs/examples/plot-acceleration.md
Normal file
10
docs/examples/plot-acceleration.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Plot Acceleration
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
led.plotBarGraph(
|
||||
input.acceleration(Dimension.X),
|
||||
1023
|
||||
)
|
||||
})
|
||||
```
|
10
docs/examples/plot-analog-pin.md
Normal file
10
docs/examples/plot-analog-pin.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Plot Analog Pin
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
led.plotBarGraph(
|
||||
pins.analogReadPin(AnalogPin.P0),
|
||||
1023
|
||||
)
|
||||
})
|
||||
```
|
10
docs/examples/plot-light-level.md
Normal file
10
docs/examples/plot-light-level.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Plot Light level
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
led.plotBarGraph(
|
||||
input.lightLevel(),
|
||||
255
|
||||
)
|
||||
})
|
||||
```
|
7
docs/examples/rando.md
Normal file
7
docs/examples/rando.md
Normal file
@ -0,0 +1,7 @@
|
||||
# Rando
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
led.toggle(Math.random(5), Math.random(5))
|
||||
})
|
||||
```
|
11
docs/faq.md
11
docs/faq.md
@ -2,4 +2,13 @@
|
||||
|
||||
### @description Frequently asked questions and answers from our users.
|
||||
|
||||
Please search for solutions or open a ticket at [support.microbit.org](https://support.microbit.org)!
|
||||
## Which web sites do I need to unblock for pxt.microbit.org?
|
||||
|
||||
This is the list of domains that need to be unblocked to allow the web editor to load:
|
||||
|
||||
* https://pxt.microbit.org
|
||||
* https://www.pxt.io
|
||||
* https://trg-microbit.userpxt.io
|
||||
* https://pxt.azureedge.net
|
||||
|
||||
Can't find your question? Please search for solutions or open a ticket at [support.microbit.org](https://support.microbit.org)!
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Getting started
|
||||
|
||||
### @description An activity for beginners to get started with the micro:bit
|
||||
### @description An activity for beginners to get started with the @boardname@
|
||||
|
||||
## ~avatar
|
||||
|
||||
@ -33,9 +33,9 @@ basic.forever(() => {
|
||||
|
||||
When this program runs, you will see a smiley face, then a blank
|
||||
screen, then a smiley again -- it never stops! (That's because of the
|
||||
``forever`` block.)
|
||||
`[basic.forever(() => {})]` block.)
|
||||
|
||||
Click **Download** to move your program to the BBC micro:bit!
|
||||
Click **Download** to move your program to the @boardname@!
|
||||
Make sure to follow the instructions.
|
||||
|
||||
### ~button /getting-started/screen
|
||||
|
@ -17,12 +17,12 @@ input.onButtonPressed(Button.A, () => {
|
||||
|
||||
#### ~hint
|
||||
|
||||
The ``showString`` block can show letters, numbers, and punctuation
|
||||
on the micro:bit screen.
|
||||
The `[basic.showString("HI")]` block can show letters, numbers, and punctuation
|
||||
on the @boardname@ screen.
|
||||
|
||||
#### ~
|
||||
|
||||
Now try to unscramble these blocks in the editor so that the micro:bit
|
||||
Now try to unscramble these blocks in the editor so that the @boardname@
|
||||
shows **BANANA** when you press button `B`.
|
||||
|
||||
```shuffle
|
||||
@ -33,11 +33,11 @@ input.onButtonPressed(Button.B, () => {
|
||||
#### ~hint
|
||||
|
||||
You can find the letter `B` by clicking the letter `A` on the
|
||||
``onButtonPressed`` block.
|
||||
`[input.onButtonPressed(Button.A, () => {})]` block.
|
||||
|
||||
#### ~
|
||||
|
||||
Click **Download** to move your program to the BBC micro:bit!
|
||||
Click **Download** to move your program to the @boardname@!
|
||||
|
||||
#### Your turn!
|
||||
|
||||
@ -48,9 +48,9 @@ name_ instead of **BANANA** when you press `B`?
|
||||
### Pins
|
||||
|
||||
You can also use the pins as buttons. (The pins are the holes in the
|
||||
metal stripe at the bottom of the micro:bit board.) For example, hold
|
||||
metal stripe at the bottom of the @boardname@ board.) For example, hold
|
||||
the ``GND`` button with one hand and touch the ``0`` pin (called
|
||||
``P0``) with your other hand to tell the micro:bit you're pressing it.
|
||||
``P0``) with your other hand to tell the @boardname@ you're pressing it.
|
||||
|
||||
Unscramble the blocks in the editor to show a heart when you touch
|
||||
pin ``P0``.
|
||||
@ -65,7 +65,7 @@ input.onPinPressed(TouchPin.P0, () => {
|
||||
. . # . .`);
|
||||
});
|
||||
```
|
||||
Click **Download** to move your program to the BBC micro:bit!
|
||||
Click **Download** to move your program to the @boardname@!
|
||||
|
||||
## ~hint
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
Are you trying to choose whether to play soccer or go to the movies
|
||||
instead, or which toppings to have on your pizza? Build a coin
|
||||
flipping machine with the BBC micro:bit to choose for you!
|
||||
flipping machine with the @boardname@ to choose for you!
|
||||
|
||||
### ~
|
||||
|
||||
@ -23,8 +23,8 @@ input.onButtonPressed(Button.B, () => {
|
||||
```
|
||||
### ~hint
|
||||
|
||||
The ``pick random true or false`` block randomly tells the ``if``
|
||||
block `true` or `false`. If the ``pick`` block picked `true`, the
|
||||
The `[Math.randomBoolean()]` block randomly tells the ``if``
|
||||
block `true` or `false`. If value picked is `true`, the
|
||||
``if`` block shows the letter `H`. Otherwise, it shows the letter `T`.
|
||||
|
||||
That's it!
|
||||
@ -50,7 +50,7 @@ input.onButtonPressed(Button.AB, () => {
|
||||
```
|
||||
|
||||
These blocks mean that if you press button `A`, you will add `1` to
|
||||
your score, and if you press `A` and `B` together, the micro:bit will
|
||||
your score, and if you press `A` and `B` together, the @boardname@ will
|
||||
show your score.
|
||||
|
||||
When you're done, your coin flipping program should look like this:
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Build a Rock Paper Scissors game with the BBC micro:bit! You can play
|
||||
the game with a friend who has it on a micro:bit. You can also play
|
||||
Build a Rock Paper Scissors game with the @boardname@! You can play
|
||||
the game with a friend who has it on a @boardname@. You can also play
|
||||
it with friends who are just using their hands. (The game is built
|
||||
like a coin flipper, but with three choices instead of two.)
|
||||
|
||||
@ -11,9 +11,9 @@ like a coin flipper, but with three choices instead of two.)
|
||||
|
||||
## Step 1: Getting started
|
||||
|
||||
We want the micro:bit to choose rock, paper, or scissors when you
|
||||
We want the @boardname@ to choose rock, paper, or scissors when you
|
||||
shake it. Try creating an ``on shake`` block so when you shake the
|
||||
micro:bit, it will run part of a program.
|
||||
@boardname@, it will run part of a program.
|
||||
|
||||
Clear up the blocks and add the blocks below.
|
||||
|
||||
@ -23,7 +23,7 @@ input.onGesture(Gesture.Shake, () => {
|
||||
})
|
||||
```
|
||||
|
||||
Next, when you shake the micro:bit, it should pick a random number from `0` to `2`
|
||||
Next, when you shake the @boardname@, it should pick a random number from `0` to `2`
|
||||
and store it in the variable `item`.
|
||||
|
||||
Add a ``set`` block with a variable. Then add a ``pick random`` block,
|
||||
@ -75,7 +75,7 @@ input.onGesture(Gesture.Shake, () => {
|
||||
|
||||
## Step 3: A random rock
|
||||
|
||||
Now we are going to add a new picture for the micro:bit to show
|
||||
Now we are going to add a new picture for the @boardname@ to show
|
||||
when another random number comes up.
|
||||
|
||||
Make the ``else if`` part check if the variable `item` is `1`.
|
||||
@ -152,7 +152,7 @@ That's why you can use an ``else`` instead of an ``else if``.
|
||||
|
||||
Your game is ready!
|
||||
|
||||
Click **Download** to move your program to the BBC micro:bit!
|
||||
Click **Download** to move your program to the @boardname@!
|
||||
|
||||
Have fun!
|
||||
|
||||
@ -160,7 +160,7 @@ Have fun!
|
||||
|
||||
Here is a way you can make your Rock Paper Scissors game better.
|
||||
When button ``A`` is pressed,
|
||||
the micro:bit will add `1` to your score.
|
||||
the @boardname@ will add `1` to your score.
|
||||
|
||||
Open the ``Game`` drawer, and then add the block ``change score by 1`` to your program,
|
||||
like this:
|
||||
@ -174,7 +174,7 @@ input.onButtonPressed(Button.A, () => {
|
||||
|
||||
## Step 6: Prove you're the greatest!
|
||||
|
||||
After your micro:bit can add `1` to the score, show how many wins you have.
|
||||
After your @boardname@ can add `1` to the score, show how many wins you have.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
@ -185,7 +185,7 @@ input.onButtonPressed(Button.A, () => {
|
||||
```
|
||||
## Step 7: Staying honest
|
||||
|
||||
Success! Your micro:bit can track wins!
|
||||
Success! Your @boardname@ can track wins!
|
||||
But what about losses?
|
||||
Use the ``Game`` drawer to subtract `1` from your score when you press button `B`.
|
||||
|
||||
@ -198,7 +198,7 @@ input.onButtonPressed(Button.B, () => {
|
||||
basic.showNumber(game.score())
|
||||
})
|
||||
```
|
||||
Click **Download** to move your program to the BBC micro:bit!
|
||||
Click **Download** to move your program to the @boardname@!
|
||||
|
||||
### ~button /projects
|
||||
NEXT: PROJECTS!
|
||||
|
@ -2,17 +2,17 @@
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
There are 25 bright LEDs on the micro:bit screen. Let's use them to create some cool animations!
|
||||
There are 25 bright LEDs on the @boardname@ screen. Let's use them to create some cool animations!
|
||||
|
||||
### ~
|
||||
|
||||
### Happy unhappy face
|
||||
|
||||
Draw an unhappy face instead of the blank screen. Click on the dots
|
||||
in the second ``show leds`` block until it matches the blocks below.
|
||||
in the second `[basic.showLeds("")]` block until it matches the blocks below.
|
||||
Now you have an **animation** (cartoon) that shows a happy face,
|
||||
then an unhappy one, then a happy one again, forever (or until
|
||||
you turn off your micro:bit)!
|
||||
you turn off your @boardname@)!
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
@ -32,11 +32,11 @@ basic.forever(() => {
|
||||
`)
|
||||
});
|
||||
```
|
||||
Click **Download** to move your program to the BBC micro:bit!
|
||||
Click **Download** to move your program to the @boardname@!
|
||||
|
||||
### Your turn!
|
||||
|
||||
Pile up more ``show leds`` blocks to create an animation! Create an
|
||||
Pile up more `[basic.showLeds("")]` blocks to create an animation! Create an
|
||||
animation with at least 5 pictures. What does this animation show?
|
||||
|
||||
```blocks
|
||||
@ -85,13 +85,7 @@ basic.forever(() => {
|
||||
`)
|
||||
});
|
||||
```
|
||||
Click **Download** to move your program to the BBC micro:bit!
|
||||
|
||||
#### ~hint
|
||||
|
||||
You can find the ``show leds`` block in the **Basic** part of the editor.
|
||||
|
||||
#### ~
|
||||
Click **Download** to move your program to the @boardname@!
|
||||
|
||||
### ~button /getting-started/buttons
|
||||
NEXT: BUTTONS
|
||||
|
@ -1,11 +1,11 @@
|
||||
# Shake
|
||||
|
||||
You can find when someone is shaking the BBC micro:bit by checking its
|
||||
**accelerometer** (it finds whether the micro:bit is speeding up or
|
||||
You can find when someone is shaking the @boardname@ by checking its
|
||||
**accelerometer** (it finds whether the @boardname@ is speeding up or
|
||||
slowing down).
|
||||
|
||||
Unscramble these blocks in the editor to show a frownie when someone
|
||||
shakes the micro:bit. (Ouch!)
|
||||
shakes the @boardname@. (Ouch!)
|
||||
|
||||
```shuffle
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
@ -17,7 +17,7 @@ input.onGesture(Gesture.Shake, () => {
|
||||
# . . . #`);
|
||||
});
|
||||
```
|
||||
Click **Download** to move your program to the BBC micro:bit!
|
||||
Click **Download** to move your program to the @boardname@!
|
||||
|
||||
### ~button /getting-started/coin-flipper
|
||||
NEXT: COIN FLIPPER GAME
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"appref": "v0.5.1"
|
||||
"appref": "v0.7.41"
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
# JavaScript
|
||||
|
||||
Visit the cards below to starting programming JavaScript and TypeScript with the micro:bit:
|
||||
Visit the cards below to starting programming JavaScript
|
||||
with the @boardname@:
|
||||
|
||||
```codecard
|
||||
[{
|
||||
|
@ -1,8 +1,8 @@
|
||||
# Call a function
|
||||
|
||||
The simplest way to get started in JavaScript with your micro:bit is to
|
||||
call one of the micro:bit's built-in JavaScript functions. Just like Blocks
|
||||
are organized into categories/drawers, the micro:bit functions are organized by
|
||||
The simplest way to get started in JavaScript with your @boardname@ is to
|
||||
call one of the @boardname@'s built-in JavaScript functions. Just like Blocks
|
||||
are organized into categories/drawers, the @boardname@ functions are organized by
|
||||
namespaces, with names corresponding to the drawer names. The `basic` namespace
|
||||
contains a number of helpful functions, such as:
|
||||
|
||||
|
@ -35,7 +35,7 @@ This calls into the constructor we defined earlier, creating a new object with t
|
||||
# Inheritance
|
||||
|
||||
### ~hint
|
||||
### Inheritance is not supported yet for the micro:bit. Coming soon...
|
||||
### Inheritance is not supported yet for the @boardname@. Coming soon...
|
||||
### ~
|
||||
|
||||
In TypeScript, we can use common object-oriented patterns.
|
||||
|
@ -1,8 +1,8 @@
|
||||
# Frequently asked questions
|
||||
|
||||
# What is the language supported for the micro:bit?
|
||||
# What is the language supported for the @boardname@?
|
||||
|
||||
For the micro:bit, we support a "static" subset of TypeScript (itself a superset of JavaScript):
|
||||
For the @boardname@, we support a "static" subset of TypeScript (itself a superset of JavaScript):
|
||||
|
||||
## Supported language features
|
||||
|
||||
|
@ -13,7 +13,7 @@ basic.showNumber(add(1, 2))
|
||||
```
|
||||
|
||||
### ~ hint
|
||||
For the micro:bit, you must specify a [type](/js/types) for each function parameter.
|
||||
For the @boardname@, you must specify a [type](/js/types) for each function parameter.
|
||||
### ~
|
||||
|
||||
Functions can refer to variables outside of the function body.
|
||||
|
@ -1,9 +1,9 @@
|
||||
## Operators
|
||||
|
||||
The following JavaScript operators are supported for the micro:bit.
|
||||
The following JavaScript operators are supported for the @boardname@.
|
||||
|
||||
### ~hint
|
||||
Note that for the micro:bit all arithmetic is performed on integers, rather than floating point.
|
||||
Note that for the @boardname@ all arithmetic is performed on integers, rather than floating point.
|
||||
This also is true when simulating in the browser.
|
||||
### ~
|
||||
|
||||
|
@ -48,7 +48,7 @@ basic.showNumber(1);
|
||||
|
||||
|
||||
### ~hint
|
||||
For the micro:bit, we don't allow a program to contain an empty statement, such as shown above.
|
||||
For the @boardname@, we don't allow a program to contain an empty statement, such as shown above.
|
||||
If you really want an empty statement, you need to use curly braces to delimit an empty statement block:
|
||||
```typescript
|
||||
while(true) { }
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Statements
|
||||
|
||||
The following JavaScript statements are supported for the micro:bit:
|
||||
The following JavaScript statements are supported for the @boardname@:
|
||||
|
||||
## Variable declarations
|
||||
* `const` statement - [read more](http://devdocs.io/javascript/statements/const)
|
||||
|
@ -15,7 +15,7 @@ let isDone: boolean = false;
|
||||
|
||||
### ~ hint
|
||||
In JavaScript, `numbers` are floating point values.
|
||||
However, for the micro:bit, `numbers` are integer values.
|
||||
However, for the @boardname@, `numbers` are integer values.
|
||||
### ~
|
||||
|
||||
Integer values can be specified via decimal, hexadecimal and octal notation:
|
||||
@ -74,7 +74,7 @@ let list: Array<number> = [1, 2, 3];
|
||||
```
|
||||
|
||||
### ~hint
|
||||
For the micro:bit, all elements of an array must have the same type.
|
||||
For the @boardname@, all elements of an array must have the same type.
|
||||
### ~
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ let c: Color = Color.Green;
|
||||
|
||||
# Any
|
||||
|
||||
The TypeScript type `any` is not supported in the micro:bit.
|
||||
The TypeScript type `any` is not supported in the @boardname@.
|
||||
|
||||
|
||||
# Void
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
## Intermediate
|
||||
|
||||
* [Magic 8](/lessons/magic-8), a fortune teller game with the BBC micro:bit
|
||||
* [Magic 8](/lessons/magic-8), a fortune teller game with the @boardname@
|
||||
* [Guess the Number](/lessons/guess-the-number), guess a random number with pick number
|
||||
* [Counter](/lessons/counter), display a number with a variable
|
||||
* [Love Meter](/lessons/love-meter), create a love meter with on pin pressed
|
||||
@ -40,7 +40,7 @@
|
||||
* [Temperature](/lessons/temperature), get the ambient temperature (degree Celsius °C)
|
||||
* [Digi Yoyo](/lessons/digi-yoyo), create a counter with a while loop
|
||||
* [Rotation Animation](/lessons/rotation-animation), control an animation with a boolean variable
|
||||
* [Compass](/lessons/compass), displays the direction the BBC micro:bit is pointing with compass
|
||||
* [Compass](/lessons/compass), displays the direction the @boardname@ is pointing with compass
|
||||
* [Zoomer](/lessons/zoomer), measure the force with acceleration
|
||||
* [Glowing Pendulum](/lessons/glowing-pendulum), construct a pendulum that glows using acceleration
|
||||
* [Classic Beatbox](/lessons/classic-beatbox), make a beatbox music player with variables
|
||||
@ -60,7 +60,7 @@
|
||||
* [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
|
||||
* [Hero](/lessons/hero), reconstruct the classic arcade game pac man with the BBC micro:bit
|
||||
* [Hero](/lessons/hero), reconstruct the classic arcade game pac man with the @boardname@
|
||||
* [Catch the Egg](/lessons/catch-the-egg-game), catch falling eggs in a basket with an acceleration controller
|
||||
### ~
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# answering machine blocks lesson
|
||||
|
||||
Create an answering machine on the BBC micro:bit
|
||||
Create an answering machine on the @boardname@
|
||||
|
||||
## Topic
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# answering machine blocks activity
|
||||
|
||||
Learn to create an answering machine on the micro:bit
|
||||
Learn to create an answering machine on the @boardname@
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
|
@ -12,7 +12,7 @@ basic.showString("ASK ME A QUESTION")
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Now we need to reply after someone asks micro:bit a yes or no question. We want to respond `YES` when button `A` is pressed. Add a condition for button `A` and inside it show the string `YES`.
|
||||
Now we need to reply after someone asks @boardname@ a yes or no question. We want to respond `YES` when button `A` is pressed. Add a condition for button `A` and inside it show the string `YES`.
|
||||
|
||||
```blocks
|
||||
basic.showString("ASK ME A QUESTION")
|
||||
@ -25,7 +25,7 @@ input.onButtonPressed(Button.A, () => {
|
||||
|
||||
### Challenge 2
|
||||
|
||||
What if micro:bit's answer to the question is no? Let's have `NO` be displayed when button `B` is pressed. Add a condition for button `B` and inside it show the string `NO`.
|
||||
What if @boardname@'s answer to the question is no? Let's have `NO` be displayed when button `B` is pressed. Add a condition for button `B` and inside it show the string `NO`.
|
||||
|
||||
```blocks
|
||||
basic.showString("ASK ME A QUESTION")
|
||||
|
@ -1,6 +1,6 @@
|
||||
# answering machine blocks quiz answers
|
||||
|
||||
Create an answering machine on the micro:bit.
|
||||
Create an answering machine on the @boardname@.
|
||||
|
||||
This is the answer key for the [answering machine quiz](/lessons/answering-machine/quiz).
|
||||
|
||||
@ -26,7 +26,7 @@ basic.showString("Hi")
|
||||

|
||||
|
||||
|
||||
## 4. If the rectangle below represents the micro:bit, write the code to display the letter "Z".
|
||||
## 4. If the rectangle below represents the @boardname@, write the code to display the letter "Z".
|
||||
|
||||

|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# answering machine blocks quiz
|
||||
|
||||
Create an answering machine on the micro:bit.
|
||||
Create an answering machine on the @boardname@.
|
||||
|
||||
## Name
|
||||
|
||||
@ -36,7 +36,7 @@ basic.showString("Hi")
|
||||
|
||||

|
||||
|
||||
## 4. If the rectangle below represents the micro:bit, write the code to display the letter "Z".
|
||||
## 4. If the rectangle below represents the @boardname@, write the code to display the letter "Z".
|
||||
|
||||
```blocks
|
||||
basic.showString("Z")
|
||||
|
@ -1,6 +1,6 @@
|
||||
# beautiful image lesson
|
||||
|
||||
Display beautiful images on the BBC micro:bit.
|
||||
Display beautiful images on the @boardname@.
|
||||
|
||||
## Topic
|
||||
|
||||
@ -14,7 +14,7 @@ Show LEDs
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
|
||||
Learn how to **show LEDs**, to show an image on the BBC micro:bit's LED screen. We will be learning how to Show LEDs using simple commands such as Show LEDs and pause.
|
||||
Learn how to **show LEDs**, to show an image on the @boardname@'s LED screen. We will be learning how to Show LEDs using simple commands such as Show LEDs and pause.
|
||||
|
||||
## Documentation
|
||||
|
||||
@ -31,6 +31,6 @@ basic.pause(100)
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to display an image on the micro:bit's LED screen
|
||||
* learn how to display an image on the @boardname@'s LED screen
|
||||
* learn how to pause your code for the specified number of milliseconds
|
||||
|
||||
|
@ -18,7 +18,7 @@ basic.showLeds(`
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Now show an new image that will display on the micro:bit.
|
||||
Now show an new image that will display on the @boardname@.
|
||||
|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
|
@ -4,19 +4,19 @@ An introduction to conditions for the Block Editor.
|
||||
|
||||
## Introduction to conditions
|
||||
|
||||
In the introduction to code, we made the BBC micro:bit automatically shows the message ‘hello world!’:
|
||||
In the introduction to code, we made the @boardname@ automatically shows the message ‘hello world!’:
|
||||
|
||||
```blocks
|
||||
basic.showString("hello world!")
|
||||
```
|
||||
|
||||
This statement, or code, will happen as soon as the BBC micro:bit is activated. This means it is unconditional. We can add a condition to make code function in certain ways:
|
||||
This statement, or code, will happen as soon as the @boardname@ is activated. This means it is unconditional. We can add a condition to make code function in certain ways:
|
||||
|
||||
* A calculator waits for the user in input numbers and a function, before outputting a result
|
||||
* A game waits for the user to press a button at the right time before outputting their score
|
||||
* A quiz waits for the user to choose the correct option, and if they are wrong the quiz will tell the user
|
||||
|
||||
In programming we use an ‘if’ statement: if this condition is met, do something. Lets add an if statement to the code we had before; the BBC Micro:bit will wait for the user to press a button before showing the image.
|
||||
In programming we use an ‘if’ statement: if this condition is met, do something. Lets add an if statement to the code we had before; the @boardname@ will wait for the user to press a button before showing the image.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
@ -40,9 +40,9 @@ You could now add additional conditions to your 'if statement'. Here are some id
|
||||
|
||||
What if the user does not press a button? What if the user presses the wrong button? We call this an else, because if the criteria of the if statement are not met then something else is done.
|
||||
|
||||
For example, we could make it so our BBC Micro:bit tells us to press the A button. Remove the `button pressed` and `show string` blocks from the `if` block and right click it and select **Delete**. Now click the **If** category and drag out an `else if` block. Plug the `button pressed` and `show string` blocks in the correct places.
|
||||
For example, we could make it so our @boardname@ tells us to press the A button. Remove the `button pressed` and `show string` blocks from the `if` block and right click it and select **Delete**. Now click the **If** category and drag out an `else if` block. Plug the `button pressed` and `show string` blocks in the correct places.
|
||||
|
||||
We want the message "Press A!" to scroll across the BBC micro:bit, so right-click the `show string` block and select **Duplicate**. Drag this new block into the `else` section and replace the “hello, world!” with "Press A!". Your code should look like this:
|
||||
We want the message "Press A!" to scroll across the @boardname@, so right-click the `show string` block and select **Duplicate**. Drag this new block into the `else` section and replace the “hello, world!” with "Press A!". Your code should look like this:
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
@ -54,7 +54,7 @@ basic.forever(() => {
|
||||
})
|
||||
```
|
||||
|
||||
So, to recap: the `forever` block makes sure our code runs forever. The BBC micro:bit checks if the user is pressing the left button, if the user is not then the “Press the button!” message will scroll across the LEDs. If the user is pressing the button then the “hello, world!” message will scroll across the screen. Check this in the simulator or attach the BBC micro:bit to the computer then click **Download** to send the code onto the BBC micro:bit.
|
||||
So, to recap: the `forever` block makes sure our code runs forever. The @boardname@ checks if the user is pressing the left button, if the user is not then the “Press the button!” message will scroll across the LEDs. If the user is pressing the button then the “hello, world!” message will scroll across the screen. Check this in the simulator or attach the @boardname@ to the computer then click **Download** to send the code onto the @boardname@.
|
||||
|
||||
## What is a condition?
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# bop it challenges
|
||||
|
||||
a game similar to "Simon Says" with the BBC micro:bit.
|
||||
a game similar to "Simon Says" with the @boardname@.
|
||||
|
||||
## Before we get started
|
||||
|
||||
|
@ -45,7 +45,7 @@ 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
|
||||
## 5. Write the code that increments the score if the @boardname@ logo is tilted down when the global variable called 'action' is equal to 1
|
||||
|
||||
```blocks
|
||||
input.onLogoDown(() => {
|
||||
@ -65,7 +65,7 @@ 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
|
||||
## 7. Write the code that increments the score if the @boardname@ is shaken when the global variable called 'action' is equal to 2
|
||||
|
||||
```blocks
|
||||
input.onLogoDown(() => {
|
||||
|
@ -26,7 +26,7 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
|
||||
|
||||
<br />
|
||||
|
||||
### 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
|
||||
### 5. Write the code that increments the score if the @boardname@ logo is tilted down when the global variable called 'action' is equal to 1
|
||||
|
||||
<br />
|
||||
|
||||
@ -34,5 +34,5 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
|
||||
|
||||
<br />
|
||||
|
||||
### 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
|
||||
### 7. Write the code that increments the score if the @boardname@ is shaken when the global variable called 'action' is equal to 2
|
||||
|
||||
|
@ -47,5 +47,5 @@ game.removeLife(1);
|
||||
* learn how to return the larger of two numbers
|
||||
* learn how to return a random number
|
||||
* learn how to return the modulus
|
||||
* learn how to show a number of the BBC micro:bit screen
|
||||
* learn how to show a number of the @boardname@ screen
|
||||
* learn how to pause your code for the specified number of milliseconds
|
||||
|
@ -43,7 +43,7 @@ eggY = eggY + 1
|
||||
led.plot(eggX, eggY)
|
||||
```
|
||||
|
||||
## 4. . Write the code that resets the egg after it has fallen past the bottom of the BBC micro:bit.
|
||||
## 4. . Write the code that resets the egg after it has fallen past the bottom of the @boardname@.
|
||||
|
||||
<br/>
|
||||
|
||||
|
@ -24,7 +24,7 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
|
||||
|
||||
<br/>
|
||||
|
||||
## 4. Write the code that resets the egg after it has fallen past the bottom of the BBC micro:bit.
|
||||
## 4. Write the code that resets the egg after it has fallen past the bottom of the @boardname@.
|
||||
|
||||
<br/>
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
# charting lesson
|
||||
|
||||
Create a charting app for simulating and measuring the acceleration applied to the micro:bit
|
||||
Create a charting app for simulating and measuring the acceleration applied to the @boardname@
|
||||
|
||||
## Topic
|
||||
|
||||
Acceleration
|
||||
|
||||
## Quick Links
|
||||
* [activity](/lessons/charting/activity)
|
||||
* [challenge](/lessons/charting/challenge)
|
||||
* [quiz](/lessons/charting/quiz)
|
||||
* [activity](/lessons/charting/activity)
|
||||
* [challenge](/lessons/charting/challenge)
|
||||
* [quiz](/lessons/charting/quiz)
|
||||
* [answers](/lessons/charting/quiz-answers)
|
||||
|
||||
## Prior learning/place of lesson in scheme of work
|
||||
@ -22,9 +22,8 @@ Learn the functions of **on data received**, **send number** and **receive numbe
|
||||
input.acceleration(Dimension.X)
|
||||
led.plotBarGraph(0, 1023)
|
||||
basic.showNumber(0)
|
||||
radio.onDataReceived(() => {})
|
||||
radio.onDataPacketReceived(() => {})
|
||||
radio.sendNumber(0)
|
||||
radio.receiveNumber()
|
||||
```
|
||||
|
||||
## Objectives
|
||||
@ -33,5 +32,5 @@ radio.receiveNumber()
|
||||
* learn how to get the acceleration value (g-force), in one of three specified dimensions
|
||||
* learn how to display a vertical bar graph based on the value and high value.
|
||||
* learn how to register code to run when a packet is received over radio
|
||||
* learn how to broadcast a number data packet to other micro:bits connected via radio
|
||||
* learn how to broadcast a number data packet to other @boardname@s connected via radio
|
||||
* learn how to read the next radio packet as a number data packet
|
||||
|
@ -1,10 +1,10 @@
|
||||
# Activity
|
||||
|
||||
Measure the acceleration on the micro:bit in the "x" direction.
|
||||
Measure the acceleration on the @boardname@ 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!
|
||||
Welcome! This activity will teach how to use the @boardname@ to chart the acceleration in the "x" direction. Let's get started!
|
||||
|
||||
|
||||
### ~
|
||||
@ -16,7 +16,7 @@ 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.
|
||||
Use the plot bar chart to visualize the acceleration on the LED screen of the @boardname@ 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(() => {
|
||||
@ -26,27 +26,27 @@ basic.forever(() => {
|
||||
```
|
||||
|
||||
### ~
|
||||
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.
|
||||
Notice that moving the @boardname@ in the simulator from left to right (x direction) changes the values beneath the @boardname@ in a range from 1023 to -1023 as measured in milli-gravities. By hovering over the @boardname@ from left to right, you can observe changing values beneath the @boardname@ simulator. Also, the LEDs shown on the Bar Graph fluctates based on the movement of the @boardname@ simulator in the x direction. The line underneath the @boardname@ 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
|
||||
NOTE: The colors of the charts reflect the color of the @boardname@ simulator. In this instance, the @boardname@ is yellow. So the color of the data line reflects the color of the @boardname@
|
||||
|
||||

|
||||
|
||||
### ~
|
||||
|
||||
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.
|
||||
Vigorously move the @boardname@ in the @boardname@ simulatator by moving the @boardname@ image from side to side. Every time the @boardname@ 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 @boardname@ from side to side, the more data being saved in Excel. After you have vigarously moved the @boardname@ simulator from side to side for a sufficient amount of time, you are ready to graph or chart the accceleration of the @boardname@. We want a printout of our acceleration on Excel that can be graphed in Excel.
|
||||
|
||||
### ~
|
||||
|
||||
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.
|
||||
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 @boardname@ in the X direction. Then click or tap on the data Excel file that was downloaded to your local ``Downloads`` Folder.
|
||||
|
||||
|
||||
### ~
|
||||
|
||||
|
||||
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
|
||||
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 @boardname@
|
||||
|
||||

|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
# Challenge
|
||||
# Challenge
|
||||
|
||||
### ~avatar avatar
|
||||
### ~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.
|
||||
Welcome! The activity will teach you how to use the acceleration of the 1st @boardname@ and to visualize the acceleration on the 2nd @boardname@.
|
||||
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.
|
||||
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 @boardname@s connected via radio.
|
||||
|
||||
```blocks
|
||||
radio.sendNumber(input.acceleration(Dimension.X));
|
||||
@ -28,37 +28,37 @@ We want to register code to run when a packet is received over radio. We can imp
|
||||
basic.forever(() => {
|
||||
radio.sendNumber(input.acceleration(Dimension.X))
|
||||
})
|
||||
radio.onDataReceived(() => {
|
||||
|
||||
radio.onDataPacketReceived(() => {
|
||||
|
||||
})
|
||||
```
|
||||
### ~
|
||||
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.
|
||||
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 @boardname@, we must implement `receive number` to constantly display a vertical bar graph based on the value. Remember, the value will equal to the @boardname@'s acceleration in the "x" direction.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
radio.sendNumber(input.acceleration(Dimension.X))
|
||||
})
|
||||
radio.onDataReceived(() => {
|
||||
led.plotBarGraph(radio.receiveNumber(), 1023)
|
||||
radio.onDataPacketReceived(({ receivedNumber }) => {
|
||||
led.plotBarGraph(receivedNumber, 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.
|
||||
Notice that moving the @boardname@ 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 @boardname@. There is a single LED turned on with the 1st @boardname@. Additionally, the graphs will reflect 0 acceleation for the 1st @boardname@. 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
|
||||
|
||||
NOTE: The colors of the charts reflect the color of the @boardname@ simulator. In this instance, the @boardname@s are blue and green. So the colors of the line graphs reflect the colors of the @boardname@
|
||||
|
||||
### ~
|
||||
After running this simulation 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.
|
||||
After running this simulation several seconds by moving the @boardname@ side to side in the x direction, you are ready to graph or chart the accceleration of the @boardname@. 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.
|
||||
Finally, you must open the Excel CSV file by clicking on the data.xls file that was downloaded to Downloads Folder.
|
||||
|
||||

|
||||
|
||||
@ -81,11 +81,11 @@ Use the Recommended Charts command on the Insert tab to quickly create a chart t
|
||||
### ~
|
||||
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"
|
||||
* Connect the first @boardname@ to your computer using your USB cable and run the charting script on it.
|
||||
* Connect the second @boardname@ to your computer using your USB cable and run the charting script on it.
|
||||
* The first person and second person take turns tilting the @boardname@ in the "x" direction while the other player charts the data on the @boardname@!
|
||||
* Review and analyze the actual @boardname@ device acceleration data on Excel
|
||||
* Display acceleration with y or z using plot bar graph by changing acceleration from "x" to "y" or "z"
|
||||
|
||||
```package
|
||||
radio
|
||||
|
@ -1,6 +1,6 @@
|
||||
# charting quiz answers
|
||||
|
||||
Measure the acceleration on the micro:bit in the "x" direction.
|
||||
Measure the acceleration on the @boardname@ in the "x" direction.
|
||||
|
||||
|
||||
## Name
|
||||
@ -25,7 +25,7 @@ We are creating a forever loop to constantly display the appropriate brightness
|
||||
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.
|
||||
## 3. After vigarously moving the @boardname@ 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/>
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# charting quiz
|
||||
|
||||
Measure the acceleration on the micro:bit in the "x" direction.
|
||||
Measure the acceleration on the @boardname@ in the "x" direction.
|
||||
|
||||
## Name
|
||||
|
||||
@ -18,6 +18,6 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
|
||||
|
||||
<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.
|
||||
## 3. After vigarously moving the @boardname@ 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.
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# classic beatbox
|
||||
|
||||
display beautiful images on the BBC micro:bit.
|
||||
display beautiful images on the @boardname@.
|
||||
|
||||
## Topic
|
||||
|
||||
@ -19,5 +19,5 @@ Learn how to make a beatbox music player using pins P1 and P2. We will be learni
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to code music on the BBC micro:bit
|
||||
* learn how to code music on the @boardname@
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# compass lesson
|
||||
|
||||
create a die on the BBC micro:bit.
|
||||
create a die on the @boardname@.
|
||||
|
||||
## Topic
|
||||
|
||||
@ -36,7 +36,7 @@ basic.showLeds(`
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to run code when the BBC micro:bit is shaken, when running code in the web browser, moving the mouse quickly simulates shaking
|
||||
* learn how to run code when the @boardname@ is shaken, when running code in the web browser, moving the mouse quickly simulates shaking
|
||||
* learn how to create a local variable as a place where you can store and retrieve data
|
||||
* learn how the assignment operator is used to declare a new local variable
|
||||
* learn how to declare a new local variable or update the value of a variable
|
||||
|
@ -1,10 +1,10 @@
|
||||
# compass activity
|
||||
|
||||
Display the direction that the micro:bit is facing using the compass
|
||||
Display the direction that the @boardname@ is facing using the compass
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Welcome! This guided tutorial will show you how to program a script that displays the direction the micro:bit is pointing. Let's get started!
|
||||
Welcome! This guided tutorial will show you how to program a script that displays the direction the @boardname@ is pointing. Let's get started!
|
||||
|
||||
### ~
|
||||
|
||||
@ -17,7 +17,7 @@ basic.forever(() => {
|
||||
})
|
||||
```
|
||||
|
||||
Store the reading of the micro:bit in a variable called `degrees`.
|
||||
Store the reading of the @boardname@ in a variable called `degrees`.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
@ -25,7 +25,7 @@ basic.forever(() => {
|
||||
})
|
||||
```
|
||||
|
||||
If `degrees` is less than `45`, then the compass heading is mostly pointing toward North. Display `N` on the micro:bit.
|
||||
If `degrees` is less than `45`, then the compass heading is mostly pointing toward North. Display `N` on the @boardname@.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
@ -36,7 +36,7 @@ basic.forever(() => {
|
||||
});
|
||||
```
|
||||
|
||||
If `degrees` is less than 135, the micro:bit is mostly pointing East. Display `E` on the micro:bit.
|
||||
If `degrees` is less than 135, the @boardname@ is mostly pointing East. Display `E` on the @boardname@.
|
||||
|
||||
|
||||
```blocks
|
||||
@ -51,7 +51,7 @@ basic.forever(() => {
|
||||
});
|
||||
```
|
||||
|
||||
If `degrees` is less than 225, the micro:bit is mostly pointing South. Display `S` on the micro:bit.
|
||||
If `degrees` is less than 225, the @boardname@ is mostly pointing South. Display `S` on the @boardname@.
|
||||
|
||||
|
||||
```blocks
|
||||
@ -70,7 +70,7 @@ basic.forever(() => {
|
||||
```
|
||||
|
||||
|
||||
If none of these conditions returned true, then the micro:bit must be pointing West. Display `W` on the micro:bit.
|
||||
If none of these conditions returned true, then the @boardname@ must be pointing West. Display `W` on the @boardname@.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
# compass challenges
|
||||
|
||||
Display the direction that the micro:bit is facing using the compass
|
||||
Display the direction that the @boardname@ is facing using the compass
|
||||
|
||||
## Before we get started
|
||||
|
||||
@ -27,7 +27,7 @@ basic.forever(() => {
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Instead of displaying `N` when the BBC micro:bit is pointing North, display a star to indicate the north star.
|
||||
Instead of displaying `N` when the @boardname@ is pointing North, display a star to indicate the north star.
|
||||
|
||||
```blocks
|
||||
let degrees = 0;
|
||||
|
@ -12,7 +12,7 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
|
||||
|
||||
## 1. What is the purpose of the 'compass heading' block?
|
||||
|
||||
Gets the compass heading of the micro:bit in degrees
|
||||
Gets the compass heading of the @boardname@ in degrees
|
||||
|
||||
|
||||
## 2. Write the code that stores the compass heading into a local variable called 'degrees'.
|
||||
@ -22,7 +22,7 @@ Gets the compass heading of the micro:bit in degrees
|
||||
let degrees = input.compassHeading()
|
||||
```
|
||||
|
||||
## 3. Write the 'If statement' that will check if the device is mostly pointing North. Display 'N' on the micro:bit
|
||||
## 3. Write the 'If statement' that will check if the device is mostly pointing North. Display 'N' on the @boardname@
|
||||
|
||||
|
||||
```blocks
|
||||
@ -32,7 +32,7 @@ if (degrees < 45) {
|
||||
}
|
||||
```
|
||||
|
||||
## 4. Write the 'If statement' that will check if the device is mostly pointing East. Display 'E' on the micro:bit
|
||||
## 4. Write the 'If statement' that will check if the device is mostly pointing East. Display 'E' on the @boardname@
|
||||
|
||||
|
||||
```blocks
|
||||
@ -42,7 +42,7 @@ if (degrees < 135) {
|
||||
}
|
||||
```
|
||||
|
||||
## 5. Write the 'If statement' that will check if the device is mostly pointing South. Display 'S' on the micro:bit
|
||||
## 5. Write the 'If statement' that will check if the device is mostly pointing South. Display 'S' on the @boardname@
|
||||
|
||||
|
||||
```blocks
|
||||
|
@ -15,12 +15,12 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
|
||||
## 2. Write the code that stores the compass heading into a local variable called 'degrees'.
|
||||
|
||||
|
||||
## 3. Write the 'If statement' that will check if the device is mostly pointing North. Display 'N' on the micro:bit
|
||||
## 3. Write the 'If statement' that will check if the device is mostly pointing North. Display 'N' on the @boardname@
|
||||
|
||||
|
||||
## 4. Write the 'If statement' that will check if the device is mostly pointing East. Display 'E' on the micro:bit
|
||||
## 4. Write the 'If statement' that will check if the device is mostly pointing East. Display 'E' on the @boardname@
|
||||
|
||||
|
||||
## 5. Write the 'If statement' that will check if the device is mostly pointing South. Display 'S' on the micro:bit
|
||||
## 5. Write the 'If statement' that will check if the device is mostly pointing South. Display 'S' on the @boardname@
|
||||
|
||||
|
||||
|
@ -33,5 +33,5 @@ input.onButtonPressed(Button.B, () => {
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Now let's try to reset the counter when the micro:bit is shaken. You will need to register an event handler with `on shake`.
|
||||
Now let's try to reset the counter when the @boardname@ is shaken. You will need to register an event handler with `on shake`.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# counter quiz answers
|
||||
|
||||
Learn how to create a counter with the BBC micro:bit button.
|
||||
Learn how to create a counter with the @boardname@ button.
|
||||
|
||||
This is the answer key for the [counter quiz](/lessons/counter/quiz).
|
||||
|
||||
@ -32,7 +32,7 @@ input.onButtonPressed(Button.A, () => {
|
||||
|
||||

|
||||
|
||||
We are only pressing on button pressed once. So the number to display on the micro:bit is also one.
|
||||
We are only pressing on button pressed once. So the number to display on the @boardname@ is also one.
|
||||
|
||||
<br/>
|
||||
|
||||
@ -48,7 +48,7 @@ input.onButtonPressed(Button.A, () => {
|
||||
|
||||

|
||||
|
||||
We included the code ``on button pressed("A")`` that runs each time the user presses A. The code increments `count` by `1`. We increase `count` by 1 whenever the user presses the button. So the third time the A button is pressed on the BBC micro:bit, the number 3 is displayed
|
||||
We included the code ``on button pressed("A")`` that runs each time the user presses A. The code increments `count` by `1`. We increase `count` by 1 whenever the user presses the button. So the third time the A button is pressed on the @boardname@, the number 3 is displayed
|
||||
|
||||
<br/>
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# counter quiz
|
||||
|
||||
Learn how to create a counter with the BBC micro:bit button.
|
||||
Learn how to create a counter with the @boardname@ button.
|
||||
|
||||
## Name
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# dice roll lesson
|
||||
|
||||
Create a dice on the BBC micro:bit.
|
||||
Create a dice on the @boardname@.
|
||||
|
||||
## Topic
|
||||
|
||||
@ -35,7 +35,7 @@ basic.showLeds(`
|
||||
|
||||
## Objectives
|
||||
|
||||
* learn how to run code when the BBC micro:bit is shaken, when running code in the web browser, moving the mouse quickly simulates shaking
|
||||
* learn how to run code when the @boardname@ is shaken, when running code in the web browser, moving the mouse quickly simulates shaking
|
||||
* learn how to create a local variable as a place where you can store and retrieve data
|
||||
* learn how the assignment operator is used to declare a new local variable
|
||||
* learn how to declare a new local variable or update the value of a variable
|
||||
|
@ -1,6 +1,6 @@
|
||||
# dice roll activity
|
||||
|
||||
Create a dice on the micro:bit
|
||||
Create a dice on the @boardname@
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
@ -8,7 +8,7 @@ Welcome! This tutorial will help you create a dice. Let's get started!
|
||||
|
||||
### ~
|
||||
|
||||
Let's create a condition for when the micro:bit is shaken.
|
||||
Let's create a condition for when the @boardname@ is shaken.
|
||||
|
||||
|
||||
```blocks
|
||||
|
@ -1,6 +1,6 @@
|
||||
# dice roll challenges
|
||||
|
||||
Create a dice on the micro:bit.
|
||||
Create a dice on the @boardname@.
|
||||
|
||||
## Before we get started
|
||||
|
||||
@ -121,7 +121,7 @@ input.onGesture(Gesture.Shake, () => {
|
||||
|
||||
### Challenge 2
|
||||
|
||||
Let's make a trick dice! Modify the line of code with `pick random` so that only numbers 3-6 can appear on the dice. Also note that we need to ensure `roll = 0` when only 1 dot is shown on the BBC micro:bit.
|
||||
Let's make a trick dice! Modify the line of code with `pick random` so that only numbers 3-6 can appear on the dice. Also note that we need to ensure `roll = 0` when only 1 dot is shown on the @boardname@.
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
@ -179,5 +179,5 @@ input.onGesture(Gesture.Shake, () => {
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Add a couple more conditions so that the BBC micro:bit randomly chooses a number between 1 and 8.
|
||||
Add a couple more conditions so that the @boardname@ randomly chooses a number between 1 and 8.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# dice roll quiz answers
|
||||
|
||||
Create a dice when the BBC micro:bit is shaken
|
||||
Create a dice when the @boardname@ is shaken
|
||||
|
||||
These are the answers to the [dice roll quiz](/lessons/dice-roll/quiz).
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# dice roll quiz
|
||||
|
||||
Create a dice when the BBC micro:bit is shaken
|
||||
Create a dice when the @boardname@ is shaken
|
||||
|
||||
## Name
|
||||
|
||||
|
@ -62,7 +62,7 @@ while (count > 0) {
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Now, we need `count` to decrease by one after the micro:bit has displayed the value of `count`.
|
||||
Now, we need `count` to decrease by one after the @boardname@ has displayed the value of `count`.
|
||||
|
||||
We can do this by adding this line:
|
||||
|
||||
|
@ -8,7 +8,7 @@ In this activity, you will learn how to blink an image on the LED screen.
|
||||
|
||||
### ~
|
||||
|
||||
Let's start by adding code that plots a heart image on the screen using `show LEDs`. Once you are done coding, don't forget to run your code in the simulator or the micro:bit.
|
||||
Let's start by adding code that plots a heart image on the screen using `show LEDs`. Once you are done coding, don't forget to run your code in the simulator or the @boardname@.
|
||||
|
||||
|
||||
```blocks
|
||||
|
@ -33,5 +33,5 @@ input.onButtonPressed(Button.B, () => {
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Now let's try to reset the counter when the micro:bit is shaken. You will need to register an event handler with `on shake`.
|
||||
Now let's try to reset the counter when the @boardname@ is shaken. You will need to register an event handler with `on shake`.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# game of chance blocks lesson
|
||||
|
||||
create an answering machine on the BBC micro:bit
|
||||
create an answering machine on the @boardname@
|
||||
|
||||
## Topic
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# game of chance blocks activity
|
||||
|
||||
Learn to create an answering machine on the micro:bit
|
||||
Learn to create an answering machine on the @boardname@
|
||||
|
||||
We will use `show string` to show text on the LED screen. *String* is a common name for *text* in programming languages. The function `show string` scrolls the text column by column at a *150* milliseconds interval. If you want to speed up or down the scrolling, simply change the *150*.
|
||||
|
||||
|
@ -28,7 +28,7 @@ input.onButtonPressed(Button.A, () => {
|
||||
|
||||
### Challenge 2
|
||||
|
||||
What if micro:bit's answer to the question is GAME OVER? Let's have `GAME OVER` be displayed when button `B` is pressed. Add a condition for button `B` and inside it show the `GAME OVER`.
|
||||
What if @boardname@'s answer to the question is GAME OVER? Let's have `GAME OVER` be displayed when button `B` is pressed. Add a condition for button `B` and inside it show the `GAME OVER`.
|
||||
|
||||
```blocks
|
||||
basic.showString("SELECT A BUTTON")
|
||||
|
@ -47,7 +47,7 @@ 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.
|
||||
Since the @boardname@ 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
|
||||
@ -64,7 +64,7 @@ basic.forever(() => {
|
||||
});
|
||||
```
|
||||
|
||||
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.
|
||||
The function `acceleration(y)` returns a number between 0 and 1024. We want to use this value for the brightness of the @boardname@, 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(`
|
||||
@ -82,7 +82,7 @@ basic.forever(() => {
|
||||
|
||||
```
|
||||
|
||||
Now let's use our acceleration value to set the brightness on the micro:bit.
|
||||
Now let's use our acceleration value to set the brightness on the @boardname@.
|
||||
|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
|
@ -28,9 +28,9 @@ basic.forever(() => {
|
||||
|
||||

|
||||
|
||||
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.
|
||||
Hold the @boardname@ in your hand in a dark room. Move the @boardname@ like a pendulum and produce a slow image that captures the pattern of the @boardname@ LEDs.
|
||||
|
||||
### 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?
|
||||
Replace "y" in `acceleration(y)` with "x" or "z". Changing the axis will cause the @boardname@ to measure the force in a different direction. What differences in the resulting pattern does this replacement make?
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user