Compare commits
102 Commits
Author | SHA1 | Date | |
---|---|---|---|
1fbf257619 | |||
932c01f394 | |||
c3b2b99d7c | |||
ec910cb10f | |||
a19d1c848b | |||
790b9f557a | |||
0b469f69b6 | |||
1a3c31c9f3 | |||
5d4bd77bf4 | |||
c83d7e9f07 | |||
efee05c7f5 | |||
cc9ab86181 | |||
ef8d7185ee | |||
b0392da8b1 | |||
c817f9e3ff | |||
5f78f98f94 | |||
395b6184b9 | |||
3274964a11 | |||
f5e8b35df4 | |||
996073728c | |||
1e964ba1ea | |||
895a099ebf | |||
f7ed06108d | |||
0ffccdca85 | |||
9f5ebdfb78 | |||
6e64e80c05 | |||
dde16fec14 | |||
e1e8eab93f | |||
dface9083f | |||
31d4afc897 | |||
8427e89eb6 | |||
277d5a721c | |||
80131f2928 | |||
51bd8d57aa | |||
acd974b964 | |||
04e0529610 | |||
ee3f2e6470 | |||
29a4f3cf69 | |||
5649495a28 | |||
a8a9d7dcf0 | |||
09d7ebaf78 | |||
5c6b4c454b | |||
7e1408fc12 | |||
09dc67717c | |||
20dcd5ce34 | |||
e092961b5b | |||
28044af979 | |||
a9ba0a8f90 | |||
871694f99f | |||
8f6c81cd53 | |||
c819b815c4 | |||
a714970344 | |||
77df714a08 | |||
693a6ba8a9 | |||
5a8122bc8a | |||
c382fc5050 | |||
d69a82d167 | |||
a30ca46fef | |||
a56226c08d | |||
87d34ba030 | |||
091917b765 | |||
aea09c1830 | |||
5e9eec61c5 | |||
a34f765681 | |||
2ae78fe6b8 | |||
33207f33e5 | |||
a487e102ef | |||
a6ffa99ceb | |||
d2aa02c259 | |||
563d76b90a | |||
b433585403 | |||
576f37171a | |||
0bd92a433d | |||
2d5f3421ba | |||
7956c6e6a1 | |||
1f7a56a451 | |||
0ea4583b20 | |||
4bccb435f7 | |||
749c2111d2 | |||
96991447f8 | |||
22f36a623b | |||
8a47793f48 | |||
5cfedf7343 | |||
13383e6232 | |||
165cd0c67e | |||
9c8886116e | |||
fc495b928e | |||
17644d4947 | |||
068ea80a45 | |||
7a86bbd6b9 | |||
78fffe0e01 | |||
7bf1a29c83 | |||
446ef4d7b7 | |||
ca3e3a43a5 | |||
2225be7af1 | |||
1ce863df96 | |||
68ae9864a9 | |||
8cd670b22a | |||
a36038a048 | |||
9d4b31fe4d | |||
3ea6d1e6bb | |||
1698c4a012 |
@ -9,7 +9,7 @@ script:
|
|||||||
- "(cd libs/lang-test1; 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 testdir tests"
|
||||||
- "node node_modules/pxt-core/built/pxt.js uploaddoc"
|
- "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-v0.json)"
|
- "(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
|
sudo: false
|
||||||
notifications:
|
notifications:
|
||||||
email:
|
email:
|
||||||
|
3
.vscode/settings.json
vendored
@ -16,5 +16,6 @@
|
|||||||
"**/pxt_modules/**": true
|
"**/pxt_modules/**": true
|
||||||
},
|
},
|
||||||
"tslint.enable": true,
|
"tslint.enable": true,
|
||||||
"tslint.rulesDirectory": "node_modules/tslint-microsoft-contrib"
|
"tslint.rulesDirectory": "node_modules/tslint-microsoft-contrib",
|
||||||
|
"typescript.tsdk": "./node_modules/typescript/lib"
|
||||||
}
|
}
|
23
cmds/cmds.ts
@ -13,17 +13,20 @@ export function deployCoreAsync(res: ts.pxtc.CompileResult) {
|
|||||||
return getBitDrivesAsync()
|
return getBitDrivesAsync()
|
||||||
.then(drives => {
|
.then(drives => {
|
||||||
if (drives.length == 0) {
|
if (drives.length == 0) {
|
||||||
console.log("cannot find any drives to deploy to")
|
console.log("cannot find any drives to deploy to");
|
||||||
} else {
|
return Promise.resolve(0);
|
||||||
console.log(`copy ${ts.pxtc.BINARY_HEX} to ` + drives.join(", "))
|
|
||||||
}
|
}
|
||||||
return Promise.map(drives, d =>
|
|
||||||
writeFileAsync(d + ts.pxtc.BINARY_HEX, res.outfiles[ts.pxtc.BINARY_HEX])
|
console.log(`copy ${ts.pxtc.BINARY_HEX} to ` + drives.join(", "));
|
||||||
.then(() => {
|
|
||||||
console.log("wrote hex file to " + d)
|
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));
|
||||||
.then(() => { })
|
};
|
||||||
|
|
||||||
|
return Promise.map(drives, d => writeHexFile(d))
|
||||||
|
.then(() => drives.length);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBitDrivesAsync(): Promise<string[]> {
|
function getBitDrivesAsync(): Promise<string[]> {
|
||||||
|
@ -1,13 +1,6 @@
|
|||||||
<script type="text/javascript">
|
|
||||||
var appInsights=window.appInsights||function(config){
|
|
||||||
function r(config){t[config]=function(){var i=arguments;t.queue.push(function(){t[config].apply(t,i)})}}var t={config:config},u=document,e=window,o="script",s=u.createElement(o),i,f;for(s.src=config.url||"//az416426.vo.msecnd.net/scripts/a/ai.0.js",u.getElementsByTagName(o)[0].parentNode.appendChild(s),t.cookie=u.cookie,t.queue=[],i=["Event","Exception","Metric","PageView","Trace"];i.length;)r("track"+i.pop());return r("setAuthenticatedUserContext"),r("clearAuthenticatedUserContext"),config.disableExceptionTracking||(i="onerror",r("_"+i),f=e[i],e[i]=function(config,r,u,e,o){var s=f&&f(config,r,u,e,o);return s!==!0&&t["_"+i](config,r,u,e,o),s}),t
|
|
||||||
}({
|
|
||||||
instrumentationKey:"e9ae05ca-350b-427a-9775-3ba3f6efabce"
|
|
||||||
});window.appInsights=appInsights;
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
(function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" ");
|
(function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" ");
|
||||||
for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,e,d])};b.__SV=1.2;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f)}})(document,window.mixpanel||[]);
|
for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,e,d])};b.__SV=1.2;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f)}})(document,window.mixpanel||[]);
|
||||||
|
mixpanel.init("762fef19c053a0ea4cec43d2fecae76e", { disable_persistence: true });
|
||||||
mixpanel.init("762fef19c053a0ea4cec43d2fecae76e");
|
if (typeof pxtConfig !== "undefined") mixpanel.register({ target: pxtConfig.targetId, version: pxtConfig.targetVersion });
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,13 +1,6 @@
|
|||||||
<script type="text/javascript">
|
|
||||||
var appInsights=window.appInsights||function(config){
|
|
||||||
function r(config){t[config]=function(){var i=arguments;t.queue.push(function(){t[config].apply(t,i)})}}var t={config:config},u=document,e=window,o="script",s=u.createElement(o),i,f;for(s.src=config.url||"//az416426.vo.msecnd.net/scripts/a/ai.0.js",u.getElementsByTagName(o)[0].parentNode.appendChild(s),t.cookie=u.cookie,t.queue=[],i=["Event","Exception","Metric","PageView","Trace"];i.length;)r("track"+i.pop());return r("setAuthenticatedUserContext"),r("clearAuthenticatedUserContext"),config.disableExceptionTracking||(i="onerror",r("_"+i),f=e[i],e[i]=function(config,r,u,e,o){var s=f&&f(config,r,u,e,o);return s!==!0&&t["_"+i](config,r,u,e,o),s}),t
|
|
||||||
}({
|
|
||||||
instrumentationKey:"e9ae05ca-350b-427a-9775-3ba3f6efabce"
|
|
||||||
});window.appInsights=appInsights;
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
(function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" ");
|
(function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" ");
|
||||||
for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,e,d])};b.__SV=1.2;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f)}})(document,window.mixpanel||[]);
|
for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,e,d])};b.__SV=1.2;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f)}})(document,window.mixpanel||[]);
|
||||||
|
mixpanel.init("762fef19c053a0ea4cec43d2fecae76e", { disable_persistence: true });
|
||||||
mixpanel.init("762fef19c053a0ea4cec43d2fecae76e");
|
if (typeof pxtConfig !== "undefined") mixpanel.register({ target: pxtConfig.targetId, version: pxtConfig.targetVersion });
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,11 +1,40 @@
|
|||||||
# crocodile clips
|
# crocodile clips
|
||||||
|
|
||||||
The large holes at the bottom of the board are designed to attach alligator/crocodile clips.
|
The large holes at the bottom of the board are designed to attach alligator/crocodile clips
|
||||||
Register an event that will execute whenever the user attaches one side of the crocodile clip to the `GND` pin, then connects and disconnects the unattached side of the crocodile clip to pin `0`, `1`, or `2`.
|
to create electrical circuit with other components.
|
||||||
|
|
||||||
### Example: on pin pressed with random numbers
|
# ~hint
|
||||||
|
|
||||||
This example displays a random number every time the crocodile clip holds `GND` then connects and disconnects the `P0` pin. Each time the crocodile clip is firmly connected and disconnected from pin `P0`, the micro:bit will return a random Number between 0 and the parameter limit
|
**No crocodile clips!?!?!** Use wires or Aluminium foil! [Read more...](/device/foil-circuits)
|
||||||
|
|
||||||
|
# ~
|
||||||
|
|
||||||
|
|
||||||
|
## Connecting Crocodile Clips
|
||||||
|
|
||||||
|
The hole for ``P0`` and ``GND`` allow to grab the board on the side which makes for a great grip.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Pass one jaw in the hole and grab the side of the board with the other jaw.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
For the center holes, ``P1`` and ``P2``, you can also grab the bottom of the board but they are a bit harder to grip.
|
||||||
|
|
||||||
|
You can also grip the board between the jaws. In which case, you will want to make sure to avoid overlapping the jaws
|
||||||
|
with the other pins as it will create short-circuit in the board.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Adding a little tape helps keeping the crocodile clips in place.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Example: on pin pressed with random numbers
|
||||||
|
|
||||||
|
This example displays a random number every time the crocodile clip holds `GND` then connects and disconnects the `P0` pin.
|
||||||
|
Each time the crocodile clip is firmly connected and disconnected from pin `P0`, the micro:bit will return a random Number between 0 and the parameter limit.
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
input.onPinPressed(TouchPin.P0, () => {
|
input.onPinPressed(TouchPin.P0, () => {
|
||||||
@ -13,11 +42,6 @@ input.onPinPressed(TouchPin.P0, () => {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Connecting Crocodile Clips
|
## See also
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
### See also
|
|
||||||
|
|
||||||
[micro:bit pins](/device/pins), [pin is pressed](/reference/input/pin-is-pressed), [analog read pin](/reference/pins/analog-read-pin), [analog write pin](/reference/pins/analog-write-pin), [digital read pin](/reference/pins/digital-read-pin), [digital write pin](/reference/pins/digital-write-pin)
|
|
||||||
|
|
||||||
|
[micro:bit pins](/device/pins)
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
# Error codes
|
# Error codes
|
||||||
|
|
||||||
The micro:bit error codes
|
|
||||||
|
|
||||||
Your micro:bit may encounter a situation that prevents it from running your code. When this happens, a frowny face will appear on your micro:bit screen (see picture) followed by an error number.
|
Your micro:bit may encounter a situation that prevents it from running your code. When this happens, a frowny face will appear on your micro:bit screen (see picture) followed by an error number.
|
||||||
|
|
||||||
Below is a list of error numbers and what they mean:
|
Below is a list of error numbers and what they mean:
|
||||||
|
52
docs/device/foil-circuits.md
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# foil circuits
|
||||||
|
|
||||||
|
The large holes at the bottom of the board are designed to attach alligator/crocodile clips
|
||||||
|
to create electrical circuit with other components.
|
||||||
|
|
||||||
|
If you do not have crocodile clips at hand, dyou can use wires or even Aluminium foil to acheive the same result.
|
||||||
|
We will show you how to connect the micro:bit to headphones using Alumunium foil and tape.
|
||||||
|
|
||||||
|
https://youtu.be/mhXYyPuvpz0
|
||||||
|
|
||||||
|
### Materials
|
||||||
|
|
||||||
|
* micro:bit and battery pack (you can also power it via USB)
|
||||||
|
* a small piece of cardboard
|
||||||
|
* Aluminium foil
|
||||||
|
* tape
|
||||||
|
|
||||||
|
### Assembly instructions
|
||||||
|
|
||||||
|
Tape the micro:bit and battery pack to the card board. Make sure to remove the batteries while you are building your circuit.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Cut the thinest strip of foil possible and roll it into a cable. You can also try to fold, whatever works for you.
|
||||||
|
Build two of those wires.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Place the foil wire on the ``GND`` pin and attach with a piece of tape. Press hard to get the best connection between
|
||||||
|
the foil and the pin board. Make sure the foil is not overlapping with the other pins!
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Place the second wire on the ``P0`` pin the same way. Make sure the wire does not overlap with the other pins!
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Tape the headphone jack connector to the cardboard and roll the wire coming from ``GND`` around the metal base.
|
||||||
|
Make sure the wire does not touch the other metal rings on the jack.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Tape the second wire on the head of the jack connector.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
[micro:bit pins](/device/pins)
|
@ -13,14 +13,8 @@ Music
|
|||||||
|
|
||||||
## Prior learning/place of lesson in scheme of work
|
## Prior learning/place of lesson in scheme of work
|
||||||
|
|
||||||
Learn how to convert your BBC micro:bit into a music player using pins P0 and GND, earphones (or speakers), as well as crocodile clips (or spring clips). We will be learning how to code musical notes using simple commands such as play, keys, and notes.
|
Learn how to convert your BBC micro:bit into a music player using pins P0 and GND, earphones (or speakers), as well as crocodile clips (or spring clips).
|
||||||
|
We will be learning how to code musical notes using simple commands such as play, keys, and notes.
|
||||||
## What the teacher needs to know / QuickStart Computing Glossary
|
|
||||||
|
|
||||||
* Hardware: The physical systems and components of digital devices; see also software.
|
|
||||||
* Programmable toys: Robots designed for children to use, accepting input, storing short sequences of simple instructions and moving according to this stored program.
|
|
||||||
* Program: A stored set of instructions encoded in a language understood by the computer that does some form of computation, processing input and/or stored data to generate output.
|
|
||||||
* Simulation: Using a computer to model the state and behaviour of real-world (or imaginary) systems, including physical or social systems; an integral part of most computer games.
|
|
||||||
|
|
||||||
## Objectives
|
## Objectives
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
# hero
|
# hero
|
||||||
|
|
||||||
make a game to test hand-eye coordination.
|
|
||||||
|
|
||||||
Make a game to test hand-eye coordination
|
Make a game to test hand-eye coordination
|
||||||
|
|
||||||
* [activity](/lessons/hero/activity)
|
* [activity](/lessons/hero/activity)
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
Here are some cool projects that you can build with your micro:bit!
|
Here are some cool projects that you can build with your micro:bit!
|
||||||
|
|
||||||
|
## Games
|
||||||
|
|
||||||
|
Fun games to build with your micro:bit.
|
||||||
|
|
||||||
```codecard
|
```codecard
|
||||||
[{
|
[{
|
||||||
@ -20,18 +23,42 @@ Here are some cool projects that you can build with your micro:bit!
|
|||||||
"name": "Rock Paper Scissors",
|
"name": "Rock Paper Scissors",
|
||||||
"url":"/projects/rock-paper-scissors",
|
"url":"/projects/rock-paper-scissors",
|
||||||
"imageUrl":"/static/mb/projects/a4-motion.png"
|
"imageUrl":"/static/mb/projects/a4-motion.png"
|
||||||
},{
|
}]
|
||||||
"name": "Compass",
|
```
|
||||||
"url":"/projects/compass",
|
|
||||||
"imageUrl":"/static/mb/projects/a5-compass.png"
|
## Maker, Arts, Fashion
|
||||||
},{
|
|
||||||
|
```codecard
|
||||||
|
[{
|
||||||
"name": "Hack your headphones",
|
"name": "Hack your headphones",
|
||||||
"url":"/projects/hack-your-headphones",
|
"url":"/projects/hack-your-headphones",
|
||||||
"imageUrl":"/static/mb/projects/a6-music.png"
|
"imageUrl":"/static/mb/projects/a6-music.png"
|
||||||
},{
|
}, {
|
||||||
"name": "Banana keyboard",
|
"name": "Banana keyboard",
|
||||||
"url":"/projects/banana-keyboard",
|
"url":"/projects/banana-keyboard",
|
||||||
"imageUrl":"/static/mb/projects/a7-conductive.png"
|
"imageUrl":"/static/mb/projects/a7-conductive.png"
|
||||||
|
}, {
|
||||||
|
"name": "Guitar",
|
||||||
|
"url":"/projects/guitar",
|
||||||
|
"imageUrl":"/static/mb/projects/guitar.png"
|
||||||
|
}, {
|
||||||
|
"name": "Watch",
|
||||||
|
"url":"/projects/the-watch",
|
||||||
|
"imageUrl":"/static/mb/projects/a10-watch.png"
|
||||||
|
}, {
|
||||||
|
"name": "Timing gates",
|
||||||
|
"url":"/projects/timing-gates",
|
||||||
|
"imageUrl":"/static/mb/projects/timing-gates.jpg"
|
||||||
|
}]
|
||||||
|
```
|
||||||
|
|
||||||
|
## More
|
||||||
|
|
||||||
|
```codecard
|
||||||
|
[{
|
||||||
|
"name": "Compass",
|
||||||
|
"url":"/projects/compass",
|
||||||
|
"imageUrl":"/static/mb/projects/a5-compass.png"
|
||||||
},{
|
},{
|
||||||
"name": "Telegraph",
|
"name": "Telegraph",
|
||||||
"url":"/projects/telegraph",
|
"url":"/projects/telegraph",
|
||||||
@ -40,13 +67,9 @@ Here are some cool projects that you can build with your micro:bit!
|
|||||||
"name": "Radio",
|
"name": "Radio",
|
||||||
"url":"/projects/radio",
|
"url":"/projects/radio",
|
||||||
"imageUrl":"/static/mb/projects/a9-radio.png"
|
"imageUrl":"/static/mb/projects/a9-radio.png"
|
||||||
},{
|
|
||||||
"name": "Watch",
|
|
||||||
"url":"/projects/the-watch",
|
|
||||||
"imageUrl":"/static/mb/projects/a10-watch.png"
|
|
||||||
}]
|
}]
|
||||||
```
|
```
|
||||||
|
|
||||||
### See Also
|
### See Also
|
||||||
|
|
||||||
[Flashing Heart](/projects/flashing-heart), [Smiley Buttons](/projects/smiley-buttons), [Love Meter](/projects/love-meter), [Rock Paper Scissors](/projects/rock-paper-scissors), [Compass](/projects/compass), [Hack your headphones](/projects/hack-your-headphones), [Banana keyboard](/projects/banana-keyboard), [Telegraph](/projects/telegraph), [Radio](/projects/radio), [Watch](/projects/the-watch)
|
[Flashing Heart](/projects/flashing-heart), [Smiley Buttons](/projects/smiley-buttons), [Love Meter](/projects/love-meter), [Rock Paper Scissors](/projects/rock-paper-scissors), [Compass](/projects/compass), [Hack your headphones](/projects/hack-your-headphones), [Banana keyboard](/projects/banana-keyboard), [Telegraph](/projects/telegraph), [Radio](/projects/radio), [Guitar](/projects/guitar), [Watch](/projects/the-watch)
|
@ -1,12 +1,16 @@
|
|||||||
# banana keyboard activity
|
# banana keyboard
|
||||||
|
|
||||||
build a banana keyboard
|
### @description A beginner maker activity, building a piano from bananas.
|
||||||
|
|
||||||
# micro:bit banana keyboard
|
### ~avatar
|
||||||
|
|
||||||
|
Build your own micro:bit piano using bananas!
|
||||||
|
|
||||||
|
### ~
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
In this project, you will build your own music player micro:bit banana keyboard from household fruit. Project duration: 15 minutes.
|
## Duration: ~20 minutes.
|
||||||
|
|
||||||
## Materials
|
## Materials
|
||||||
|
|
||||||
@ -15,86 +19,11 @@ In this project, you will build your own music player micro:bit banana keyboard
|
|||||||
* Orange
|
* Orange
|
||||||
* Crocodile clips
|
* Crocodile clips
|
||||||
|
|
||||||
## Steps
|
## Activities
|
||||||
|
|
||||||
### Step 1
|
* [Making the keyboard](/projects/banana-keyboard/making)
|
||||||
|
* [Beat box](/projects/banana-keyboard/beat-box)
|
||||||

|
|
||||||
|
|
||||||
Using the 1st crocodile clip, connect the end of the crocodile clip onto GND pin on the micro:bit.
|
|
||||||
|
|
||||||
### Step 2
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Using the 2nd crocodile clip, connect the end of the crocodile clip onto the 0 pin on the micro:bit.
|
|
||||||
|
|
||||||
### Step 3
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Using the 1st crocodile clip, connect the second end of the crocodile clip onto based of the headphone jack.
|
|
||||||
|
|
||||||
### Step 4
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Using the 2nd crocodile clip, connect the second end of the crocodile clip onto tip of the headphone jack.
|
|
||||||
|
|
||||||
### Step 5
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Using the 3rd crocodile clip, connect the end of the crocodile clip onto the 1st crocodile clip already clipped onto GND.
|
|
||||||
|
|
||||||
### Step 6
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Using the 3rd crocodile clip, connect the unattached end of the crocodile clip onto the orange.
|
|
||||||
|
|
||||||
### Step 7
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Using the 4th crocodile clip, connect the end of the crocodile clip onto pin 1 on the micro:bit.
|
|
||||||
|
|
||||||
### Step 8
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Using the 4th crocodile clip, connect the unattached end of the crocodile clip onto the banana.
|
|
||||||
|
|
||||||
### Step 9
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Your banana keyboard is ready!
|
|
||||||
|
|
||||||
### Step 10
|
|
||||||
|
|
||||||
Connect your micro:bit to your computer using your USB cable and run this script:
|
|
||||||
```blocks
|
|
||||||
let sound = music.noteFrequency(Note.C);
|
|
||||||
input.onPinPressed(TouchPin.P1, () => {
|
|
||||||
for (let i = 0; i < 5; i++) {
|
|
||||||
sound = sound + 25;
|
|
||||||
music.playTone(sound, music.beat(BeatFraction.Sixteenth));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Tap your banana instrument to play sound against... the fruit!
|
|
||||||
|
|
||||||
|
|
||||||
### ~avatar boothing
|
|
||||||
|
|
||||||
Excellent, you're ready to continue with the [challenges](/projects/banana-keyboard-challenges)!
|
|
||||||
|
|
||||||
|
### ~button /projects/banana-keyboard/making
|
||||||
|
Let's get started!
|
||||||
### ~
|
### ~
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
# banana keyboard blocks challenges
|
# banana keyboard - beat box
|
||||||
|
|
||||||
control images with variables.
|
|
||||||
|
|
||||||
## Before we get started
|
|
||||||
|
|
||||||
Control images with variables.
|
|
||||||
|
|
||||||
Have you ever tried to making beat box sounds? Let's try making a beatbox with code!
|
Have you ever tried to making beat box sounds? Let's try making a beatbox with code!
|
||||||
|
|
||||||
@ -35,7 +29,7 @@ input.onPinPressed(TouchPin.P1, () => {
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
* click *run* to see if the code works as expected.
|
* click *Download* to see if the code works as expected.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -57,8 +51,4 @@ input.onPinPressed(TouchPin.P2, () => {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
* click *run* to see if the code works as expected.
|
* click *Download* to see if the code works as expected.
|
||||||
|
|
||||||
### ~button /projects/telegraph
|
|
||||||
NEXT: Telegraph
|
|
||||||
### ~
|
|
85
docs/projects/banana-keyboard/making.md
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
# banana keyboard - making
|
||||||
|
|
||||||
|
## Materials
|
||||||
|
|
||||||
|
* micro:bit, battery holder and 2 AAA batteries
|
||||||
|
* Bananas
|
||||||
|
* Orange
|
||||||
|
* Crocodile clips
|
||||||
|
|
||||||
|
## Steps
|
||||||
|
|
||||||
|
### Step 1
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 1st crocodile clip, connect the end of the crocodile clip onto GND pin on the micro:bit.
|
||||||
|
|
||||||
|
### Step 2
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 2nd crocodile clip, connect the end of the crocodile clip onto the 0 pin on the micro:bit.
|
||||||
|
|
||||||
|
### Step 3
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 1st crocodile clip, connect the second end of the crocodile clip onto based of the headphone jack.
|
||||||
|
|
||||||
|
### Step 4
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 2nd crocodile clip, connect the second end of the crocodile clip onto tip of the headphone jack.
|
||||||
|
|
||||||
|
### Step 5
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 3rd crocodile clip, connect the end of the crocodile clip onto the 1st crocodile clip already clipped onto GND.
|
||||||
|
|
||||||
|
### Step 6
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 3rd crocodile clip, connect the unattached end of the crocodile clip onto the orange.
|
||||||
|
|
||||||
|
### Step 7
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 4th crocodile clip, connect the end of the crocodile clip onto pin 1 on the micro:bit.
|
||||||
|
|
||||||
|
### Step 8
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 4th crocodile clip, connect the unattached end of the crocodile clip onto the banana.
|
||||||
|
|
||||||
|
### Step 9
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Your banana keyboard is ready!
|
||||||
|
|
||||||
|
### Step 10
|
||||||
|
|
||||||
|
Connect your micro:bit to your computer using your USB cable and run this script:
|
||||||
|
```blocks
|
||||||
|
input.onPinPressed(TouchPin.P1, () => {
|
||||||
|
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Tap your banana instrument to play sound against... the fruit!
|
||||||
|
|
||||||
|
### ~button /projects/banana-keyboard/beat-box
|
||||||
|
NEXT: beat box
|
||||||
|
### ~
|
@ -103,7 +103,3 @@ basic.forever(() => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### ~button /projects/hack-your-headphones
|
|
||||||
NEXT: Hack Your Headphones
|
|
||||||
### ~
|
|
@ -7,11 +7,12 @@
|
|||||||
```sim
|
```sim
|
||||||
basic.forever(() => {
|
basic.forever(() => {
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
# # # # #
|
# # # # #
|
||||||
# # # # #
|
# # # # #
|
||||||
. # # # .
|
. # # # .
|
||||||
. . # . .`);
|
. . # . .`
|
||||||
|
);
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
basic.clearScreen();
|
basic.clearScreen();
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
@ -29,11 +30,12 @@ Use [show leds](/reference/basic/show-leds) and make your code look like this:
|
|||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
# # # # #
|
# # # # #
|
||||||
# # # # #
|
# # # # #
|
||||||
. # # # .
|
. # # # .
|
||||||
. . # . .`);
|
. . # . .`
|
||||||
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Step 2
|
## Step 2
|
||||||
@ -42,11 +44,11 @@ Add a [pause](/reference/basic/pause) to wait and [clear screen](/reference/basi
|
|||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
# # # # #
|
# # # # #
|
||||||
# # # # #
|
# # # # #
|
||||||
. # # # .
|
. # # # .
|
||||||
. . # . .`);
|
. . # . .`);
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
basic.clearScreen();
|
basic.clearScreen();
|
||||||
```
|
```
|
||||||
@ -58,11 +60,12 @@ Put a [forever loop](/reference/basic/forever) around it.
|
|||||||
```blocks
|
```blocks
|
||||||
basic.forever(() => {
|
basic.forever(() => {
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
# # # # #
|
# # # # #
|
||||||
# # # # #
|
# # # # #
|
||||||
. # # # .
|
. # # # .
|
||||||
. . # . .`);
|
. . # . .`
|
||||||
|
);
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
basic.clearScreen();
|
basic.clearScreen();
|
||||||
})
|
})
|
||||||
@ -75,11 +78,12 @@ Add a [pause](/reference/basic/pause) to wait after clearing the screen.
|
|||||||
```blocks
|
```blocks
|
||||||
basic.forever(() => {
|
basic.forever(() => {
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
# # # # #
|
# # # # #
|
||||||
# # # # #
|
# # # # #
|
||||||
. # # # .
|
. # # # .
|
||||||
. . # . .`);
|
. . # . .`
|
||||||
|
);
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
basic.clearScreen();
|
basic.clearScreen();
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
@ -94,26 +98,24 @@ Add a second image of a broken heart.
|
|||||||
```blocks
|
```blocks
|
||||||
basic.forever(() => {
|
basic.forever(() => {
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
# # # # #
|
# # # # #
|
||||||
# # # # #
|
# # # # #
|
||||||
. # # # .
|
. # # # .
|
||||||
. . # . .`);
|
. . # . .`
|
||||||
|
);
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
basic.clearScreen();
|
basic.clearScreen();
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
# . # # #
|
# . # # #
|
||||||
# . . . #
|
# . . . #
|
||||||
. # # # .
|
. # # # .
|
||||||
. . # . .`);
|
. . # . .`
|
||||||
|
);
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
basic.clearScreen();
|
basic.clearScreen();
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### ~button /projects/smiley-buttons
|
|
||||||
NEXT: Smiley Buttons
|
|
||||||
### ~
|
|
@ -1,5 +1,7 @@
|
|||||||
# Guitar
|
# Guitar
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### @description A beginner-intermediate maker activity, building a guitar with the micro:bit
|
### @description A beginner-intermediate maker activity, building a guitar with the micro:bit
|
||||||
|
|
||||||
### ~avatar avatar
|
### ~avatar avatar
|
||||||
@ -15,8 +17,9 @@ https://youtu.be/GYmdTFvxz80
|
|||||||
5 Activities, approx 30-45 min each based on familiarity with the coding concepts
|
5 Activities, approx 30-45 min each based on familiarity with the coding concepts
|
||||||
|
|
||||||
## Materials
|
## Materials
|
||||||
|
|
||||||
* Cardboard large pieces (recycle!)
|
* Cardboard large pieces (recycle!)
|
||||||
* Tape (masking, duct Tape, and/or packing tape)
|
* Tape (masking, duct tape, and/or packing tape)
|
||||||
* Markers and/or paint
|
* Markers and/or paint
|
||||||
* Aluminum Foil
|
* Aluminum Foil
|
||||||
* Scissors that can cut cardboard
|
* Scissors that can cut cardboard
|
||||||
@ -25,6 +28,7 @@ https://youtu.be/GYmdTFvxz80
|
|||||||
* Headphones
|
* Headphones
|
||||||
|
|
||||||
## Activities
|
## Activities
|
||||||
|
|
||||||
* [Making the Guitar Body](/projects/guitar/making)
|
* [Making the Guitar Body](/projects/guitar/making)
|
||||||
* [Buttons, Display & Sound](/projects/guitar/displaybuttons)
|
* [Buttons, Display & Sound](/projects/guitar/displaybuttons)
|
||||||
* [Light Sensor Tone control](/projects/guitar/lightsensor)
|
* [Light Sensor Tone control](/projects/guitar/lightsensor)
|
||||||
@ -32,5 +36,7 @@ https://youtu.be/GYmdTFvxz80
|
|||||||
* [Pin Press Switch](/projects/guitar/pinpress)
|
* [Pin Press Switch](/projects/guitar/pinpress)
|
||||||
|
|
||||||
### ~button /projects/guitar/making
|
### ~button /projects/guitar/making
|
||||||
|
|
||||||
Let's get started!
|
Let's get started!
|
||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
### ~avatar avatar
|
### ~avatar avatar
|
||||||
|
|
||||||
Use the Accelerometer to control guitar tempo
|
Use the Accelerometer to control guitar tempo
|
||||||
* Duration: 30 - 45 minutes
|
|
||||||
* Concepts:
|
* Concepts:
|
||||||
* Gravity
|
* Gravity
|
||||||
* Acceleration
|
* Acceleration
|
||||||
@ -18,9 +17,11 @@ Use the Accelerometer to control guitar tempo
|
|||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
|
## Duration: 30 - 45 minutes
|
||||||
|
|
||||||
*accelerometer controlled tempo*
|
*accelerometer controlled tempo*
|
||||||
https://youtu.be/h_gPkBaVkoo
|
https://youtu.be/kA0HpqCWsjs
|
||||||
TODO: add sound to video
|
|
||||||
## Blocks
|
## Blocks
|
||||||
|
|
||||||
```cards
|
```cards
|
||||||
|
@ -165,7 +165,7 @@ From **Music**, drag **play tone *C* for *1* beat** block under the **show leds*
|
|||||||
**Try the A & B buttons** with headphones and power connected
|
**Try the A & B buttons** with headphones and power connected
|
||||||
|
|
||||||
## Congratulations on completing the basic guitar!
|
## Congratulations on completing the basic guitar!
|
||||||
**Challenge:** Create Samples of longer music to play for each button instead of the single tone
|
**Challenge:** Create samples of longer music to play for each button instead of the single tone
|
||||||
* *Tip*: Search for "ABC music notation" or "Easy Music Notes" + the name of a song
|
* *Tip*: Search for "ABC music notation" or "Easy Music Notes" + the name of a song
|
||||||
|
|
||||||
## Extra
|
## Extra
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
### ~avatar avatar
|
### ~avatar avatar
|
||||||
|
|
||||||
Use the Light Sensor to control guitar Tone
|
Use the Light Sensor to the control tone for this [Theremin](https://en.wikipedia.org/wiki/Theremin) inspired guitar
|
||||||
* **Duration:** 30 - 45 minutes
|
|
||||||
* **Concepts:**
|
* **Concepts:**
|
||||||
* Inputs
|
* Inputs
|
||||||
* Light Intensity
|
* Light Intensity
|
||||||
@ -13,11 +13,10 @@ Use the Light Sensor to control guitar Tone
|
|||||||
* Ratio Mapping
|
* Ratio Mapping
|
||||||
* Forever Loop
|
* Forever Loop
|
||||||
* Math (multiplication) with code properties
|
* Math (multiplication) with code properties
|
||||||
* **Resources:**
|
|
||||||
* This guitar is inspired by the [Theremin](https://en.wikipedia.org/wiki/Theremin)
|
|
||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
|
## Duration: 30 - 45 minutes
|
||||||
|
|
||||||
*playing tones with light sensor*
|
*playing tones with light sensor*
|
||||||
https://youtu.be/2cKg9pokVC4
|
https://youtu.be/2cKg9pokVC4
|
||||||
|
|
||||||
@ -25,7 +24,7 @@ https://youtu.be/2cKg9pokVC4
|
|||||||
|
|
||||||
- the micro:bit can detect external light level intensity reaching the LEDs
|
- the micro:bit can detect external light level intensity reaching the LEDs
|
||||||
- the light level block reports a reading of values 0 (*dark*) to 255 (*bright*)
|
- the light level block reports a reading of values 0 (*dark*) to 255 (*bright*)
|
||||||
- a **Forever Loop** is required to continually use measure the current light level to control the tone
|
- a **Forever Loop** is required to continually measure the current light level and control the tone
|
||||||
|
|
||||||
## Forever Loop
|
## Forever Loop
|
||||||
|
|
||||||
@ -72,8 +71,8 @@ Experiment to see the effect on graph height when the **plot bar graph** value *
|
|||||||
```blocks
|
```blocks
|
||||||
music.playTone(261, music.beat(BeatFraction.Half))
|
music.playTone(261, music.beat(BeatFraction.Half))
|
||||||
```
|
```
|
||||||
**play tone** blocks can specify a specific numeric **Frequency**
|
**play tone** blocks can specify a numeric **Frequency**
|
||||||
by replacing the letter note 261Hz represents a **C** note with a **number** block
|
by replacing the letter **C** note with a **number** block that has the value it represents
|
||||||
```blocks
|
```blocks
|
||||||
music.playTone(261, music.beat(BeatFraction.Half))
|
music.playTone(261, music.beat(BeatFraction.Half))
|
||||||
```
|
```
|
||||||
@ -85,7 +84,7 @@ input.onButtonPressed(Button.A, () => {
|
|||||||
music.playTone(261 * 2, music.beat(BeatFraction.Half))
|
music.playTone(261 * 2, music.beat(BeatFraction.Half))
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
create a **play tone** block using a **Math** section, **multiplication** block to set *tone*
|
Create a **play tone** block using a **Math** section, **multiplication** block to set *tone*
|
||||||
|
|
||||||
### Next
|
### Next
|
||||||
**Add** a **B** button block that multiplies the **261** tone by a number other than 2 to set tone
|
**Add** a **B** button block that multiplies the **261** tone by a number other than 2 to set tone
|
||||||
|
@ -11,7 +11,7 @@ Make the Guitar Body for your micro:bit Guitar
|
|||||||
|
|
||||||
## Materials
|
## Materials
|
||||||
* Cardboard large pieces (recycle!)
|
* Cardboard large pieces (recycle!)
|
||||||
* Tape (masking, duct Tape, and/or packing tape)
|
* Tape (masking, duct tape, and/or packing tape)
|
||||||
* Scissors that can cut cardboard
|
* Scissors that can cut cardboard
|
||||||
* Markers and/or paint
|
* Markers and/or paint
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ the shape of your guitar
|
|||||||
### ~hint
|
### ~hint
|
||||||
|
|
||||||
* Avoid small details that are difficult to cut into cardboard
|
* Avoid small details that are difficult to cut into cardboard
|
||||||
* Unfolding a box gives longer pieces of cardboard, and creases can be reinforced
|
* Unfolding a box gives longer pieces of cardboard and creases can be reinforced
|
||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ https://youtu.be/aUQkrFoEank
|
|||||||
|
|
||||||
## Step 3: Personalize the Guitar
|
## Step 3: Personalize the Guitar
|
||||||
|
|
||||||
Create unique styling using tape, markers, paint and other available materials (*calling all artist!*)
|
Create unique styles using tape, markers, paint and other available materials (*calling all artists!*)
|
||||||
|
|
||||||
*decorating the guitar*
|
*decorating the guitar*
|
||||||
https://youtu.be/zNAZTJeSxY8
|
https://youtu.be/zNAZTJeSxY8
|
||||||
|
@ -4,9 +4,7 @@
|
|||||||
|
|
||||||
### ~avatar avatar
|
### ~avatar avatar
|
||||||
Use pin press to switch guitar play on/off
|
Use pin press to switch guitar play on/off
|
||||||
* **Duration:** approximately 45 minutes
|
|
||||||
* **Materials:**
|
|
||||||
* 2-3 Crocodile clips
|
|
||||||
* Concepts:
|
* Concepts:
|
||||||
* Circuit
|
* Circuit
|
||||||
* Conductor
|
* Conductor
|
||||||
@ -15,6 +13,11 @@ Use pin press to switch guitar play on/off
|
|||||||
* Boolean: **`True`/`False`**
|
* Boolean: **`True`/`False`**
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
|
## Duration: approximately 45 minutes
|
||||||
|
|
||||||
|
## Materials:
|
||||||
|
2-3 Crocodile clips
|
||||||
|
|
||||||
## Blocks
|
## Blocks
|
||||||
|
|
||||||
```cards
|
```cards
|
||||||
@ -122,7 +125,7 @@ input.onPinPressed(TouchPin.P1, () => {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
## Now Play!
|
## Now Play!
|
||||||
**Turn the guitar ON and OFF with a pin press on the connected foil**
|
**Turn the guitar ON and OFF with a pin press on the connected foil by**
|
||||||
**touching both pieces of foil at the same time to connect the switches**
|
**touching both pieces of foil at the same time to connect the switches**
|
||||||
|
|
||||||
https://youtu.be/GYmdTFvxz80
|
https://youtu.be/GYmdTFvxz80
|
@ -1,12 +1,17 @@
|
|||||||
# hack your headphones
|
# hack your headphones
|
||||||
|
|
||||||
Hack your headphones
|
### @description A beginner maker activity, building a piano from bananas.
|
||||||
|
|
||||||
# micro:bit music
|
### ~avatar
|
||||||
|
|
||||||
|
Build your own music player micro:bit from headphones.
|
||||||
|
|
||||||
|
### ~
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
In this project, you will build your own music player micro:bit from headphones. Project duration: 15 minutes.
|
|
||||||
|
## Duration: ~15 minutes.
|
||||||
|
|
||||||
## Materials
|
## Materials
|
||||||
|
|
||||||
@ -14,48 +19,19 @@ In this project, you will build your own music player micro:bit from headphones.
|
|||||||
* Headphones
|
* Headphones
|
||||||
* Crocodile clips
|
* Crocodile clips
|
||||||
|
|
||||||
## Steps
|
## Activities
|
||||||
|
|
||||||
### Step 1
|
* [Connect your headphone](/projects/hack-your-headphone/making)
|
||||||
|
* [Play sounds!]()
|
||||||
|
|
||||||

|
# ~hint
|
||||||
|
|
||||||
Using the 1st crocodile clip, connect the end of the crocodile clip onto GND pin on the micro:bit.
|
**No crocodile clips!?!?!** Use wires or Aluminium foil! [Read more...](/device/foil-circuits)
|
||||||
|
|
||||||
### Step 2
|
# ~
|
||||||
|
|
||||||

|
### ~button /projects/hack-your-headphones/making
|
||||||
|
|
||||||

|
Let's get started!
|
||||||
|
|
||||||
Using the 2nd crocodile clip, connect the end of the crocodile clip onto the 0 pin on the micro:bit.
|
|
||||||
|
|
||||||
### Step 3
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Using the 1st crocodile clip, connect the second end of the crocodile clip onto based of the headphone jack. The base of your headphone jack is considered the ground so it is connected to the GND of the micro:bit.
|
|
||||||
|
|
||||||
### Step 4
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Using the 2nd crocodile clip, connect the second end of the crocodile clip onto the tip of the headphone jack. The tip of your headphone jack feeds into the right speaker on the headphone. You connect from the micro:bit pin 0 to the tip of the right side of your headphone. Use the tip of the headphone jack to play sounds.
|
|
||||||
|
|
||||||
### Step 5
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
You hacked your headphones!
|
|
||||||
|
|
||||||
### Step 6
|
|
||||||
|
|
||||||
Connect your micro:bit to your computer using your USB cable and program [light beatbox](/projects/hack-your-headphones-challenges) music on it. Press the reset button to restart your music player!
|
|
||||||
|
|
||||||
### ~avatar avatar
|
|
||||||
|
|
||||||
Excellent, you're ready to continue with the [challenges](/projects/hack-your-headphones-challenges)!
|
|
||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
53
docs/projects/hack-your-headphones/making.md
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# hack your headphones - making
|
||||||
|
|
||||||
|
### ~avatar avatar
|
||||||
|
|
||||||
|
Did you know you could attach your headhpones to the micro:bit to generate sounds?
|
||||||
|
|
||||||
|
### ~
|
||||||
|
|
||||||
|
# ~hint
|
||||||
|
|
||||||
|
**No crocodile clips!?!?!** Use wires or Aluminium foil! [Read more...](/device/foil-circuits)
|
||||||
|
|
||||||
|
# ~
|
||||||
|
|
||||||
|
### Step 1
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 1st crocodile clip, connect the end of the crocodile clip onto GND pin on the micro:bit.
|
||||||
|
|
||||||
|
### Step 2
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 2nd crocodile clip, connect the end of the crocodile clip onto the 0 pin on the micro:bit.
|
||||||
|
|
||||||
|
### Step 3
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 1st crocodile clip, connect the second end of the crocodile clip onto based of the headphone jack. The base of your headphone jack is considered the ground so it is connected to the GND of the micro:bit.
|
||||||
|
|
||||||
|
### Step 4
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 2nd crocodile clip, connect the second end of the crocodile clip onto the tip of the headphone jack. The tip of your headphone jack feeds into the right speaker on the headphone. You connect from the micro:bit pin 0 to the tip of the right side of your headphone. Use the tip of the headphone jack to play sounds.
|
||||||
|
|
||||||
|
### Step 5
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
You hacked your headphones!
|
||||||
|
|
||||||
|
### ~button /projects/hack-your-headphones/music-of-light
|
||||||
|
|
||||||
|
NEXT: music of light
|
||||||
|
|
||||||
|
### ~
|
@ -1,6 +1,4 @@
|
|||||||
# hack your headphones challenges
|
# hack your headphones - music of light
|
||||||
|
|
||||||
Control sound with the light level.
|
|
||||||
|
|
||||||
### ~avatar avatar
|
### ~avatar avatar
|
||||||
|
|
||||||
@ -70,7 +68,3 @@ input.onButtonPressed(Button.A, () => {
|
|||||||
```
|
```
|
||||||
|
|
||||||
* click **Download** and run your code on the micro:bit.
|
* click **Download** and run your code on the micro:bit.
|
||||||
|
|
||||||
### ~button /projects/banana-keyboard
|
|
||||||
NEXT: Banana Keyboard
|
|
||||||
### ~
|
|
@ -48,7 +48,3 @@ input.onPinPressed(TouchPin.P2, () => {
|
|||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### ~button /projects/rock-paper-scissors
|
|
||||||
NEXT: Rock Paper Scissors
|
|
||||||
### ~
|
|
@ -89,10 +89,6 @@ Have fun reviewing your simulation and analyze the acceleration by chart the Exc
|
|||||||
* Review and analyze the actual micro:bit device acceleration data on Excel
|
* 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"
|
* Display acceleration with y or z using plot bar graph by changing acceleration from "x" to "y" or "z"
|
||||||
|
|
||||||
### ~button /projects/the-watch
|
|
||||||
NEXT: The Watch
|
|
||||||
### ~
|
|
||||||
|
|
||||||
```package
|
```package
|
||||||
microbit-radio
|
microbit-radio
|
||||||
```
|
```
|
||||||
|
@ -236,6 +236,3 @@ input.onButtonPressed(Button.B, () => {
|
|||||||
How else can you make your game better?
|
How else can you make your game better?
|
||||||
Ever hear of [Rock Paper Scissors Spock Lizard](http://www.samkass.com/theories/RPSSL.html)?
|
Ever hear of [Rock Paper Scissors Spock Lizard](http://www.samkass.com/theories/RPSSL.html)?
|
||||||
|
|
||||||
### ~button /projects/compass
|
|
||||||
NEXT: Compass
|
|
||||||
### ~
|
|
@ -10,11 +10,12 @@ Use [show leds](/reference/basic/show-leds) to make a smiley face:
|
|||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
. # . # .
|
. # . # .
|
||||||
. . . . .
|
. . . . .
|
||||||
# . . . #
|
# . . . #
|
||||||
. # # # .`);
|
. # # # .`
|
||||||
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Step 2
|
## Step 2
|
||||||
@ -24,18 +25,20 @@ frowny face inside it:
|
|||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
. # . # .
|
. # . # .
|
||||||
. . . . .
|
. . . . .
|
||||||
# . . . #
|
# . . . #
|
||||||
. # # # .`);
|
. # # # .`
|
||||||
|
);
|
||||||
input.onButtonPressed(Button.A, () => {
|
input.onButtonPressed(Button.A, () => {
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
. # . # .
|
. # . # .
|
||||||
. . . . .
|
. . . . .
|
||||||
. # # # .
|
. # # # .
|
||||||
# . . . #`);
|
# . . . #`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -45,18 +48,20 @@ Now add blocks so that when [button B is pressed](/reference/input/button-is-pre
|
|||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
. # . # .
|
. # . # .
|
||||||
. . . . .
|
. . . . .
|
||||||
# . . . #
|
# . . . #
|
||||||
. # # # .`);
|
. # # # .`
|
||||||
|
);
|
||||||
input.onButtonPressed(Button.A, () => {
|
input.onButtonPressed(Button.A, () => {
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
. # . # .
|
. # . # .
|
||||||
. . . . .
|
. . . . .
|
||||||
. # # # .
|
. # # # .
|
||||||
# . . . #`);
|
# . . . #`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
input.onButtonPressed(Button.B, () => {
|
input.onButtonPressed(Button.B, () => {
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
@ -64,10 +69,7 @@ input.onButtonPressed(Button.B, () => {
|
|||||||
. # . # .
|
. # . # .
|
||||||
. . . . .
|
. . . . .
|
||||||
# . . . #
|
# . . . #
|
||||||
. # # # .`);
|
. # # # .`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### ~button /projects/love-meter
|
|
||||||
NEXT: Love Meter
|
|
||||||
### ~
|
|
@ -1,75 +1,25 @@
|
|||||||
# telegraph activity
|
# telegraph activity
|
||||||
|
|
||||||
Build a telgraph.
|
|
||||||
|
|
||||||
# micro:bit telegraph
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
In this project, you will build your telegraph between micro:bits. Project duration: 15 minutes.
|
### ~avatar
|
||||||
|
|
||||||
|
Build a telegraph between two micro:bits to communicate with your friends!
|
||||||
|
|
||||||
|
### ~
|
||||||
|
|
||||||
|
## Duration: ~30 minutes
|
||||||
|
|
||||||
## Materials
|
## Materials
|
||||||
|
|
||||||
* micro:bit, battery holder and 2 AAA batteries
|
* micro:bit, battery holder and 2 AAA batteries
|
||||||
* Crocodile clips
|
* Crocodile clips
|
||||||
|
|
||||||
## Steps
|
## Activities
|
||||||
|
|
||||||
### Step 1
|
* [Making the circuit](/projects/telegraph/making)
|
||||||
|
* [Manual telegraph](/projects/telegraph/manual-telegraph)
|
||||||

|
|
||||||
|
|
||||||
Using the 1st crocodile clip, connect the end of the crocodile clip onto GND pin on the micro:bit.
|
|
||||||
|
|
||||||
### Step 2
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Using the 2nd crocodile clip, connect the end of the crocodile clip onto the 3V pin on the micro:bit.
|
|
||||||
|
|
||||||
### Step 3
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Using the 3rd crocodile clip, connect the end of the crocodile clip onto pin 1 of the micro:bit.
|
|
||||||
|
|
||||||
### Step 4
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Using the 4th crocodile clip, connect the end of the crocodile clip onto pin 2 of the micro:bit.
|
|
||||||
|
|
||||||
### Step 5
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Using the 1st crocodile clip, connect the unattached end of the crocodile clip onto the GND on the 2nd micro:bit.
|
|
||||||
|
|
||||||
### Step 6
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Using the 2nd crocodile clip, connect the unattached end of the crocodile clip onto the 3V pin on the 2nd micro:bit.
|
|
||||||
|
|
||||||
### Step 7
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Using the 3rd crocodile clip, connect the unattached end of the crocodile clip onto pin 2 of the 2nd micro:bit.
|
|
||||||
|
|
||||||
### Step 8
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Using the 4th crocodile clip, connect the unattached end of the crocodile clip onto pin 1 of the 2nd micro:bit
|
|
||||||
|
|
||||||
### Step 9
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
### ~avatar avatar
|
|
||||||
|
|
||||||
Excellent, you're ready to continue with the [challenges](/projects/telegraph-challenges)!
|
|
||||||
|
|
||||||
|
### ~button /projects/telegraph/making
|
||||||
|
Let's get started!
|
||||||
### ~
|
### ~
|
||||||
|
75
docs/projects/telegraph/making.md
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
# telegraph - making
|
||||||
|
|
||||||
|
### ~avatar
|
||||||
|
|
||||||
|
Let's build a telegraph between two micro:bits.
|
||||||
|
|
||||||
|
### ~
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Materials
|
||||||
|
|
||||||
|
* micro:bit, battery holder and 2 AAA batteries
|
||||||
|
* Crocodile clips
|
||||||
|
|
||||||
|
## Steps
|
||||||
|
|
||||||
|
### Step 1
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 1st crocodile clip, connect the end of the crocodile clip onto GND pin on the micro:bit.
|
||||||
|
|
||||||
|
### Step 2
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 2nd crocodile clip, connect the end of the crocodile clip onto the 3V pin on the micro:bit.
|
||||||
|
|
||||||
|
### Step 3
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 3rd crocodile clip, connect the end of the crocodile clip onto pin 1 of the micro:bit.
|
||||||
|
|
||||||
|
### Step 4
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 4th crocodile clip, connect the end of the crocodile clip onto pin 2 of the micro:bit.
|
||||||
|
|
||||||
|
### Step 5
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 1st crocodile clip, connect the unattached end of the crocodile clip onto the GND on the 2nd micro:bit.
|
||||||
|
|
||||||
|
### Step 6
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 2nd crocodile clip, connect the unattached end of the crocodile clip onto the 3V pin on the 2nd micro:bit.
|
||||||
|
|
||||||
|
### Step 7
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 3rd crocodile clip, connect the unattached end of the crocodile clip onto pin 2 of the 2nd micro:bit.
|
||||||
|
|
||||||
|
### Step 8
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Using the 4th crocodile clip, connect the unattached end of the crocodile clip onto pin 1 of the 2nd micro:bit
|
||||||
|
|
||||||
|
### Step 9
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
### ~button /projects/telegraph/manual-telegraph
|
||||||
|
|
||||||
|
NEXT: manual telegraph
|
||||||
|
|
||||||
|
### ~
|
@ -1,18 +1,10 @@
|
|||||||
# telegraph activity
|
# telegraph - manual telegraph
|
||||||
|
|
||||||
Build a telegraph.
|
Let's build the code that will send a impulse while the user presses ``A``.
|
||||||
|
|
||||||
# micro:bit telegraph
|
|
||||||
|
|
||||||
Have you ever tried to communicate through a telegraph? Let's try coding a "Telegraph" on two BBC micro:bits !
|
|
||||||
|
|
||||||
Complete the following [tutorial](/projects/telegraph), your hack should look like this:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
### Step 1
|
### Step 1
|
||||||
|
|
||||||
We now need to digitally write to the specified pin (P0) as digital. Let's start by adding the code in the pin drawer that includes 'digital write (0,1) to pin P0'.. Then insert 1 for digital write.
|
We now need to digitally write to pin ``P0`` as **high** (1).
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
pins.digitalWritePin(DigitalPin.P0, 1)
|
pins.digitalWritePin(DigitalPin.P0, 1)
|
||||||
@ -21,7 +13,8 @@ pins.digitalWritePin(DigitalPin.P0, 1)
|
|||||||
|
|
||||||
### Step 2
|
### Step 2
|
||||||
|
|
||||||
We want to add a block to turn on an LED in the middle area of the LED display using plot x, y. So insert the appropriate LED plot x, y.
|
We want to add a block to turn on an LED in the middle area of the LED display using plot x, y.
|
||||||
|
So insert the appropriate LED plot x, y.
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
pins.digitalWritePin(DigitalPin.P0, 1)
|
pins.digitalWritePin(DigitalPin.P0, 1)
|
||||||
@ -31,7 +24,8 @@ led.plot(2, 2)
|
|||||||
|
|
||||||
### Step 3
|
### Step 3
|
||||||
|
|
||||||
We want to insert a condition that tells us when to turn on the LED. So insert the if block under logic drawer. Then add a condition that occurs if we do not turn on a LED with plot x, y. We also should plot an LED on the display if button A is pressed. Your code should appear as follows:
|
We want to insert a condition that tells us when to turn on the LED. So insert the if block under logic drawer.
|
||||||
|
Then add a condition that occurs if we do not turn on a LED with plot x, y. We also should plot an LED on the display if button A is pressed. Your code should appear as follows:
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
if (input.buttonIsPressed(Button.A)) {
|
if (input.buttonIsPressed(Button.A)) {
|
||||||
@ -45,7 +39,7 @@ if (input.buttonIsPressed(Button.A)) {
|
|||||||
|
|
||||||
### Step 4
|
### Step 4
|
||||||
|
|
||||||
We want to write code if button A is NOT pressed. It is important to say that digital write is not on. We also want to turn off all LED lights on the LED screen
|
We want to write code if button A is NOT pressed. It is important to say that digital write is not on. We also want to turn off all the LED light.
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
if (input.buttonIsPressed(Button.A)) {
|
if (input.buttonIsPressed(Button.A)) {
|
||||||
@ -53,7 +47,7 @@ if (input.buttonIsPressed(Button.A)) {
|
|||||||
led.plot(2, 2)
|
led.plot(2, 2)
|
||||||
} else {
|
} else {
|
||||||
pins.digitalWritePin(DigitalPin.P0, 0)
|
pins.digitalWritePin(DigitalPin.P0, 0)
|
||||||
basic.clearScreen()
|
led.unplot(2, 2)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -66,25 +60,22 @@ basic.forever(() => {
|
|||||||
if (input.buttonIsPressed(Button.A)) {
|
if (input.buttonIsPressed(Button.A)) {
|
||||||
pins.digitalWritePin(DigitalPin.P0, 1)
|
pins.digitalWritePin(DigitalPin.P0, 1)
|
||||||
led.plot(2, 2)
|
led.plot(2, 2)
|
||||||
} else {
|
} else {
|
||||||
pins.digitalWritePin(DigitalPin.P0, 0)
|
pins.digitalWritePin(DigitalPin.P0, 0)
|
||||||
basic.clearScreen()
|
led.unplot(2, 2)
|
||||||
}
|
})
|
||||||
})
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 6
|
### Step 6
|
||||||
|
|
||||||
|
|
||||||
We now need to digitally read to the specified pin (P1) as digital. Let's start by going to the pin drawer and adding digital read pin (0,1) and changing the pin to P1. Now we need to create a condition for digital read pin (0,1). So we go to the logic drawer and select the comparison operator. Then we want to set the comparison operator to 1 to turn on digital read on pin 1. We want to insert a condition that tells us if button A is pressed and we should turn on digital read on pin 1. So insert the if block under logic drawer. Then add a condition that occurs if digital read on P1 is on. Then we want to plot x, y at the x, y coordinates of 2,2. we also want to say that if digital read pin P1 is not on, we want to turn off all LED lights on the screen. Your code should appear as follows:
|
We now need to digitally read to the specified pin (P1) as digital. Let's start by going to the pin drawer and adding digital read pin (0,1) and changing the pin to P1. Now we need to create a condition for digital read pin (0,1). So we go to the logic drawer and select the comparison operator. Then we want to set the comparison operator to 1 to turn on digital read on pin 1. We want to insert a condition that tells us if button A is pressed and we should turn on digital read on pin 1. So insert the if block under logic drawer. Then add a condition that occurs if digital read on P1 is on. Then we want to plot x, y at the x, y coordinates of 2,2. we also want to say that if digital read pin P1 is not on, we want to turn off all LED lights on the screen. Your code should appear as follows:
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
if (pins.digitalReadPin(DigitalPin.P1) == 1) {
|
if (pins.digitalReadPin(DigitalPin.P1) == 1) {
|
||||||
led.plot(2, 2);
|
led.plot(4, 4);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
basic.clearScreen();
|
led.unplot(4, 4);
|
||||||
}
|
}
|
||||||
basic.forever(() => {
|
basic.forever(() => {
|
||||||
if (input.buttonIsPressed(Button.A)) {
|
if (input.buttonIsPressed(Button.A)) {
|
||||||
@ -108,7 +99,3 @@ Your telegraph is ready!
|
|||||||
* Connect the first micro:bit to your computer using your USB cable and put the telegraph script on it.
|
* Connect the first micro:bit to your computer using your USB cable and put the telegraph script on it.
|
||||||
* Connect the second micro:bit to your computer using your USB cable and run the telegraph script on it.
|
* Connect the second micro:bit to your computer using your USB cable and run the telegraph script on it.
|
||||||
* The first person and second person take turns pressing button A to play the telegraph game!
|
* The first person and second person take turns pressing button A to play the telegraph game!
|
||||||
|
|
||||||
### ~button /projects/radio
|
|
||||||
NEXT: Radio
|
|
||||||
### ~
|
|
231
docs/projects/timing-gates.md
Normal file
@ -0,0 +1,231 @@
|
|||||||
|
# Timing gates
|
||||||
|
|
||||||
|
### ~avatar
|
||||||
|
|
||||||
|
This project explains the principles of timing gates using household materials.
|
||||||
|
|
||||||
|
### ~
|
||||||
|
|
||||||
|
## Timing gates
|
||||||
|
|
||||||
|
The two gates are connected to the micro:bit and can detect a car passing through.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
As the car passes through the gate ``0``, it sends an event to the micro:bit through the [on pin pressed](/reference/input/on-pin-pressed) block.
|
||||||
|
The micro:bit records the time in a variable ``t0``.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
As the car passes through the gate ``1``, it sends an event to the micro:bit through the [on pin pressed](/reference/input/on-pin-pressed) block.
|
||||||
|
The micro:bit records the time in a variable ``t1``.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The rest is a bit of math and physics. The time taken to cross the gates is computed as the difference of ``t1 - t0``.
|
||||||
|
By dividing the distance between the gates by the duration, we get the speed of the car!
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
## Materials
|
||||||
|
|
||||||
|
* Carboard
|
||||||
|
* Aluminum fail
|
||||||
|
* Double-side tape (carpet tape)
|
||||||
|
* 4 crocodile clips
|
||||||
|
* A micro:bit board and USB cable
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## blocks
|
||||||
|
|
||||||
|
```cards
|
||||||
|
basic.showLeds(`
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
. . # . .
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
`)
|
||||||
|
input.onPinPressed(TouchPin.P0, () => {})
|
||||||
|
let t = 0
|
||||||
|
input.runningTime()
|
||||||
|
t - 1
|
||||||
|
control.eventTimestamp();
|
||||||
|
basic.showNumber(0)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building the gate
|
||||||
|
|
||||||
|
The sensor is made by tapping two strips of fail on the cardboard as close as possible.
|
||||||
|
|
||||||
|
Add two strips of double-sided tape on the cardboard. Remove the protective film.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Lay the Aluminum foil on the double-sided tape. Press firmly on the tape to get a good bonding of the foil.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Strip the out foil around and between the tape strips. Make sure both foil strips don't touch each other.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Connect a crocodile strip to each foil strip.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Connect the crocodile plugs to the ``GND`` and ``P0`` pins on the micro:bit.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The gate is ready to use! Your circuit should look like the picture below:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
## Detecting the car with code
|
||||||
|
|
||||||
|
The micro:bit provides an event [on pin pressed](/reference/pins/on-pin-pressed)
|
||||||
|
that is raised when a circuit between ``GND`` and a pin is detected. The circuit conductor could be a wire or even your body!
|
||||||
|
We will attach a foil to the bottom of the car. When it passes over the gate, it connect both foil strips, close the circuit and trigger the event.
|
||||||
|
|
||||||
|
Open the [code editor](/) and start a new project and add the following blocks. Notice that we are using pin ``P0`` here.
|
||||||
|
|
||||||
|
```blocks
|
||||||
|
basic.showLeds(`
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
. . # . .
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
`)
|
||||||
|
input.onPinPressed(TouchPin.P0, () => {
|
||||||
|
basic.showLeds(`
|
||||||
|
# . . . .
|
||||||
|
# . . . .
|
||||||
|
# . . . .
|
||||||
|
# . . . .
|
||||||
|
# . . . .
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
Testing the code with our finger, we see a LED column turn on when pressing both strips.
|
||||||
|
|
||||||
|
https://youtu.be/zi_-NAmdDpY
|
||||||
|
|
||||||
|
## Upgrading the car
|
||||||
|
|
||||||
|
In this lesson, we picked a random toy car and tapped foil to the bottom.
|
||||||
|
As the car goes through the gate, it will connect both sides of the gate and trigger it. Make sure to add enough foil to get a good connection on the ground.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
By moving the car (slowly) through the gate, you will see that it triggers the ``on pin pressed`` event.
|
||||||
|
|
||||||
|
https://youtu.be/M3DIUvDPlIA
|
||||||
|
|
||||||
|
### ~hint
|
||||||
|
|
||||||
|
It does not work always! Sometimes the foil does not touch long enough both strip to be detected. This is due to the poor quality of our sensor.
|
||||||
|
To fix this, you would have to consider using better sensors based on IR or Hall effect.
|
||||||
|
|
||||||
|
### ~
|
||||||
|
|
||||||
|
## Adding the second gate
|
||||||
|
|
||||||
|
Repeat the same process with tape and foil to build the first gate.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Connect the crocodile plugs to the ``GND`` and ``P1`` pins on the micro:bit.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Detecting the second gate
|
||||||
|
|
||||||
|
Since the second gate is connected to pin ``P1``, we add a second [on pin pressed](/reference/pins/on-pin-pressed) event
|
||||||
|
that display 2 columns of LEDs.
|
||||||
|
|
||||||
|
```blocks
|
||||||
|
basic.showLeds(`
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
. . # . .
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
`)
|
||||||
|
input.onPinPressed(TouchPin.P0, () => {
|
||||||
|
basic.showLeds(`
|
||||||
|
# . . . .
|
||||||
|
# . . . .
|
||||||
|
# . . . .
|
||||||
|
# . . . .
|
||||||
|
# . . . .
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
input.onPinPressed(TouchPin.P1, () => {
|
||||||
|
basic.showLeds(`
|
||||||
|
# . . . #
|
||||||
|
# . . . #
|
||||||
|
# . . . #
|
||||||
|
# . . . #
|
||||||
|
# . . . #
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
```
|
||||||
|
Strolling the car over both gates, you can see how the first gate triggers then the second.
|
||||||
|
|
||||||
|
https://youtu.be/N4bWQcu6yWs
|
||||||
|
|
||||||
|
## Computing time
|
||||||
|
|
||||||
|
The micro:bit has a clock that measures time precisely. It measures how many seconds the micro:bit has been on.
|
||||||
|
We will record the time where each gate is tripped in variables ``t0`` and ``t1``.
|
||||||
|
We take the different between ``t1`` and ``t0`` to compute the duration between the gates.
|
||||||
|
|
||||||
|
```blocks
|
||||||
|
let t0 = 0;
|
||||||
|
let t1 = 0;
|
||||||
|
basic.showLeds(`
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
. . # . .
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
`)
|
||||||
|
input.onPinPressed(TouchPin.P0, () => {
|
||||||
|
t0 = control.eventTimestamp();
|
||||||
|
basic.showLeds(`
|
||||||
|
# . . . .
|
||||||
|
# . . . .
|
||||||
|
# . . . .
|
||||||
|
# . . . .
|
||||||
|
# . . . .
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
input.onPinPressed(TouchPin.P1, () => {
|
||||||
|
t1 = control.eventTimestamp();
|
||||||
|
basic.showLeds(`
|
||||||
|
# . . . #
|
||||||
|
# . . . #
|
||||||
|
# . . . #
|
||||||
|
# . . . #
|
||||||
|
# . . . #
|
||||||
|
`)
|
||||||
|
let d = t1 - t0
|
||||||
|
basic.showNumber(d)
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
https://youtu.be/piyym_ux1EM
|
||||||
|
|
||||||
|
## Computing velocity
|
||||||
|
|
||||||
|
Measure the distance between the gates and apply Newton's laws to compute the velocity of the car.
|
||||||
|
|
||||||
|
v = d / t
|
||||||
|
|
||||||
|
We'll let you try to code this one on your own!
|
@ -1,20 +1,11 @@
|
|||||||
# Raspberry Pi and Raspbian
|
# Raspberry Pi and Raspbian
|
||||||
|
|
||||||
It is possible to run the web editor or [command line interface](/cli) from Raspbian on Raspberry Pi 2 or 3.
|
It is possible to run the web editor or [command line interface](/cli) from Raspbian on Raspberry Pi 2 or 3
|
||||||
|
with [Raspbian Jessie with Pixel](https://www.raspberrypi.org/downloads/raspbian/).
|
||||||
|
|
||||||
## Web editor
|
## Web editor
|
||||||
|
|
||||||
The web editor requires to install IceWeasel (Firefox) as the built-in browser cannot handle it.
|
Starting with **Raspbian Pixel**, Raspbian comes with Chromium. Simply open [](https://codethemicrobit.com).
|
||||||
|
|
||||||
```
|
|
||||||
sudo apt-get install iceweasel
|
|
||||||
```
|
|
||||||
|
|
||||||
Once installed simply navigate to https://codethemicrobit.com or type
|
|
||||||
|
|
||||||
```
|
|
||||||
firefox https://codethemicrobit.com
|
|
||||||
```
|
|
||||||
|
|
||||||
## Command line
|
## Command line
|
||||||
|
|
||||||
|
@ -10,6 +10,10 @@ input.onButtonPressed(Button.A, () => {
|
|||||||
music.playTone(0, 0);
|
music.playTone(0, 0);
|
||||||
led.plot(0, 0);
|
led.plot(0, 0);
|
||||||
radio.sendNumber(0);
|
radio.sendNumber(0);
|
||||||
|
```
|
||||||
|
## Advanced
|
||||||
|
|
||||||
|
```namespaces
|
||||||
game.addScore(1);
|
game.addScore(1);
|
||||||
images.createImage(`
|
images.createImage(`
|
||||||
. . . . .
|
. . . . .
|
||||||
@ -24,7 +28,8 @@ control.inBackground(() => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
## Advanced
|
|
||||||
|
## Bluetooth
|
||||||
|
|
||||||
```namespaces
|
```namespaces
|
||||||
devices.tellCameraTo(MesCameraEvent.TakePhoto);
|
devices.tellCameraTo(MesCameraEvent.TakePhoto);
|
||||||
|
@ -23,13 +23,16 @@ Rather than just sharing the link, you can also embed the project so that your v
|
|||||||
|
|
||||||
### General instructions
|
### General instructions
|
||||||
|
|
||||||
* Copy the HTML for embedding the page from the publish dialog. It will look like the following:
|
Select the kind of embedding you would like.
|
||||||
|
|
||||||
```html
|
* **Screenshot** - a lightweight screenshot of the blocks that links to the snippet
|
||||||
<div class="ui card sim"><div class="ui content"><div style="position:relative;height:0;padding-bottom:70%;overflow:hidden;"><iframe style="position:absolute;top:0;left:0;width:100%;height:100%;" src="https://codethemicrobit.com/?sandbox=1#pub:httuftrbtg" allowfullscreen="allowfullscreen" frameborder="0"></iframe></div></div></div>
|
* **Editor** - embedded editor with minimal UI
|
||||||
```
|
* **Simulator** - embedded simulator only
|
||||||
|
* **Command line** - specific instructions to unpack the project using the [command line](/cli) tools
|
||||||
|
|
||||||
* Open the HTML editor for your blog or website and paste it with your content
|
Copy the HTML for embedding the page from the publish dialog. It will look like the following:
|
||||||
|
|
||||||
|
Open the HTML editor for your blog or website and paste it with your content
|
||||||
|
|
||||||
### Wordpress
|
### Wordpress
|
||||||
|
|
||||||
|
BIN
docs/static/embed/embed-info.png
vendored
Before Width: | Height: | Size: 113 KiB After Width: | Height: | Size: 20 KiB |
BIN
docs/static/mb/device/croc-clips/badclamp.jpg
vendored
Normal file
After Width: | Height: | Size: 35 KiB |
BIN
docs/static/mb/device/croc-clips/crocclipsclamped.jpg
vendored
Normal file
After Width: | Height: | Size: 91 KiB |
BIN
docs/static/mb/device/croc-clips/foilcircuit.jpg
vendored
Normal file
After Width: | Height: | Size: 78 KiB |
BIN
docs/static/mb/device/croc-clips/foilcut.jpg
vendored
Normal file
After Width: | Height: | Size: 79 KiB |
BIN
docs/static/mb/device/croc-clips/frontclamp.jpg
vendored
Normal file
After Width: | Height: | Size: 93 KiB |
BIN
docs/static/mb/device/croc-clips/groundconnected.jpg
vendored
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
docs/static/mb/device/croc-clips/jackconnect.jpg
vendored
Normal file
After Width: | Height: | Size: 43 KiB |
BIN
docs/static/mb/device/croc-clips/jackground.jpg
vendored
Normal file
After Width: | Height: | Size: 47 KiB |
BIN
docs/static/mb/device/croc-clips/microbitattached.jpg
vendored
Normal file
After Width: | Height: | Size: 85 KiB |
BIN
docs/static/mb/device/croc-clips/microbitconnect.jpg
vendored
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
docs/static/mb/device/croc-clips/sideclamp.jpg
vendored
Normal file
After Width: | Height: | Size: 34 KiB |
BIN
docs/static/mb/projects/timing-gates.jpg
vendored
Normal file
After Width: | Height: | Size: 8.1 KiB |
BIN
docs/static/mb/projects/timing-gates/carfoil.jpg
vendored
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
docs/static/mb/projects/timing-gates/connectcrocs.jpg
vendored
Normal file
After Width: | Height: | Size: 56 KiB |
BIN
docs/static/mb/projects/timing-gates/connectsensor.jpg
vendored
Normal file
After Width: | Height: | Size: 75 KiB |
BIN
docs/static/mb/projects/timing-gates/materials.jpg
vendored
Normal file
After Width: | Height: | Size: 75 KiB |
BIN
docs/static/mb/projects/timing-gates/sensor2.jpg
vendored
Normal file
After Width: | Height: | Size: 69 KiB |
BIN
docs/static/mb/projects/timing-gates/sensordone.jpg
vendored
Normal file
After Width: | Height: | Size: 78 KiB |
BIN
docs/static/mb/projects/timing-gates/sensormicrobit2.jpg
vendored
Normal file
After Width: | Height: | Size: 70 KiB |
BIN
docs/static/mb/projects/timing-gates/sketchgate1.jpg
vendored
Normal file
After Width: | Height: | Size: 52 KiB |
BIN
docs/static/mb/projects/timing-gates/sketchgate2.jpg
vendored
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
docs/static/mb/projects/timing-gates/sketchgates.jpg
vendored
Normal file
After Width: | Height: | Size: 53 KiB |
BIN
docs/static/mb/projects/timing-gates/sketchmath.jpg
vendored
Normal file
After Width: | Height: | Size: 70 KiB |
BIN
docs/static/mb/projects/timing-gates/spreadfoil.jpg
vendored
Normal file
After Width: | Height: | Size: 91 KiB |
BIN
docs/static/mb/projects/timing-gates/stickfoil.jpg
vendored
Normal file
After Width: | Height: | Size: 87 KiB |
BIN
docs/static/mb/projects/timing-gates/tape.jpg
vendored
Normal file
After Width: | Height: | Size: 108 KiB |
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "microbit-bluetooth",
|
"name": "bluetooth",
|
||||||
"description": "Bluetooth services",
|
"description": "Bluetooth services",
|
||||||
"files": [
|
"files": [
|
||||||
"README.md",
|
"README.md",
|
||||||
@ -10,7 +10,7 @@
|
|||||||
],
|
],
|
||||||
"public": true,
|
"public": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"microbit": "file:../microbit"
|
"core": "file:../core"
|
||||||
},
|
},
|
||||||
"yotta": {
|
"yotta": {
|
||||||
"config": {
|
"config": {
|
80
libs/core/_locales/ja/core-strings.json
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
{
|
||||||
|
"Math.randomBoolean|block": "pick random true or false",
|
||||||
|
"Math|block": "Math",
|
||||||
|
"String.fromCharCode|block": "text from char code %code",
|
||||||
|
"String|block": "String",
|
||||||
|
"basic.clearScreen|block": "clear screen",
|
||||||
|
"basic.forever|block": "forever",
|
||||||
|
"basic.pause|block": "pause (ms) %pause",
|
||||||
|
"basic.showLeds|block": "show leds",
|
||||||
|
"basic.showNumber|block": "show|number %number",
|
||||||
|
"basic.showString|block": "show|string %text",
|
||||||
|
"basic|block": "basic",
|
||||||
|
"control.inBackground|block": "run in background",
|
||||||
|
"control.reset|block": "reset",
|
||||||
|
"control.waitMicros|block": "wait (µs)%micros",
|
||||||
|
"control|block": "control",
|
||||||
|
"game.addScore|block": "change score by|%points",
|
||||||
|
"game.gameOver|block": "game over",
|
||||||
|
"game.score|block": "score",
|
||||||
|
"game.startCountdown|block": "start countdown|(ms) %duration",
|
||||||
|
"game|block": "game",
|
||||||
|
"images.createBigImage|block": "create big image",
|
||||||
|
"images.createImage|block": "create image",
|
||||||
|
"images|block": "images",
|
||||||
|
"input.acceleration|block": "acceleration (mg)|%NAME",
|
||||||
|
"input.buttonIsPressed|block": "button|%NAME|is pressed",
|
||||||
|
"input.compassHeading|block": "compass heading (°)",
|
||||||
|
"input.lightLevel|block": "light level",
|
||||||
|
"input.magneticForce|block": "magnetic force (µT)|%NAME",
|
||||||
|
"input.onButtonPressed|block": "on button|%NAME|pressed",
|
||||||
|
"input.onGesture|block": "on |%NAME",
|
||||||
|
"input.onPinPressed|block": "on pin %NAME|pressed",
|
||||||
|
"input.onPinReleased|block": "on pin %NAME|released",
|
||||||
|
"input.pinIsPressed|block": "pin %NAME|is pressed",
|
||||||
|
"input.rotation|block": "rotation (°)|%NAME",
|
||||||
|
"input.runningTime|block": "running time (ms)",
|
||||||
|
"input.setAccelerometerRange|block": "set accelerometer|range %range",
|
||||||
|
"input.temperature|block": "temperature (°C)",
|
||||||
|
"input|block": "input",
|
||||||
|
"led.brightness|block": "brightness",
|
||||||
|
"led.plotBarGraph|block": "plot bar graph of %value |up to %high",
|
||||||
|
"led.plot|block": "plot|x %x|y %y",
|
||||||
|
"led.point|block": "point|x %x|y %y",
|
||||||
|
"led.setBrightness|block": "set brightness %value",
|
||||||
|
"led.stopAnimation|block": "stop animation",
|
||||||
|
"led.toggle|block": "toggle|x %x|y %y",
|
||||||
|
"led.unplot|block": "unplot|x %x|y %y",
|
||||||
|
"led|block": "led",
|
||||||
|
"music.beat|block": "%fraction|beat",
|
||||||
|
"music.changeTempoBy|block": "change tempo by (bpm)|%value",
|
||||||
|
"music.noteFrequency|block": "%note",
|
||||||
|
"music.playTone|block": "play|tone %note=device_note|for %duration=device_beat",
|
||||||
|
"music.rest|block": "rest(ms)|%duration=device_beat",
|
||||||
|
"music.ringTone|block": "ring tone (Hz)|%note=device_note",
|
||||||
|
"music.setTempo|block": "set tempo to (bpm)|%value",
|
||||||
|
"music.tempo|block": "tempo (bpm)",
|
||||||
|
"music|block": "music",
|
||||||
|
"pins.analogReadPin|block": "analog read|pin %name",
|
||||||
|
"pins.analogSetPeriod|block": "analog set period|pin %pin|to (µs)%micros",
|
||||||
|
"pins.analogWritePin|block": "analog write|pin %name|to %value",
|
||||||
|
"pins.digitalReadPin|block": "digital read|pin %name",
|
||||||
|
"pins.digitalWritePin|block": "digital write|pin %name|to %value",
|
||||||
|
"pins.i2cReadNumber|block": "i2c read number|at address %address|of format %format=i2c_sizeof",
|
||||||
|
"pins.i2cWriteNumber|block": "i2c write number|at address %address|with value %value|of format %format=i2c_sizeof",
|
||||||
|
"pins.map|block": "map %value|from low %fromLow|from high %fromHigh|to low %toLow|to high %toHigh",
|
||||||
|
"pins.onPulsed|block": "on|pin %pin|pulsed %pulse",
|
||||||
|
"pins.pulseDuration|block": "pulse duration (µs)",
|
||||||
|
"pins.servoSetPulse|block": "servo set pulse|pin %value|to (µs) %micros",
|
||||||
|
"pins.servoWritePin|block": "servo write|pin %name|to %value",
|
||||||
|
"pins.setPull|block": "set pull|pin %pin|to %pull",
|
||||||
|
"pins.spiWrite|block": "spi write %value",
|
||||||
|
"pins|block": "pins",
|
||||||
|
"serial.readLine|block": "serial read line",
|
||||||
|
"serial.redirect|block": "serial redirect to|TX %tx|RX %rx|at baud rate %rate",
|
||||||
|
"serial.writeLine|block": "serial|write line %text",
|
||||||
|
"serial.writeNumber|block": "serial|write number %value",
|
||||||
|
"serial.writeString|block": "serial write string %text",
|
||||||
|
"serial.writeValue|block": "serial|write value %name|= %value",
|
||||||
|
"serial|block": "serial"
|
||||||
|
}
|
@ -110,6 +110,7 @@ enum EventBusValue {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//% weight=1 color="#333333"
|
//% weight=1 color="#333333"
|
||||||
|
//% advanced=true
|
||||||
namespace control {
|
namespace control {
|
||||||
void fiberDone(void *a)
|
void fiberDone(void *a)
|
||||||
{
|
{
|
@ -2,6 +2,7 @@
|
|||||||
* Runtime and event utilities.
|
* Runtime and event utilities.
|
||||||
*/
|
*/
|
||||||
//% weight=1 color="#333333"
|
//% weight=1 color="#333333"
|
||||||
|
//% advanced=true
|
||||||
namespace control {
|
namespace control {
|
||||||
|
|
||||||
/**
|
/**
|
@ -22,6 +22,7 @@ enum LedSpriteProperty {
|
|||||||
* A single-LED sprite game engine
|
* A single-LED sprite game engine
|
||||||
*/
|
*/
|
||||||
//% color=#008272 weight=32
|
//% color=#008272 weight=32
|
||||||
|
//% advanced=true
|
||||||
namespace game {
|
namespace game {
|
||||||
let _score: number = 0;
|
let _score: number = 0;
|
||||||
let _life: number = 3;
|
let _life: number = 3;
|
@ -4,6 +4,7 @@
|
|||||||
* Creation, manipulation and display of LED images.
|
* Creation, manipulation and display of LED images.
|
||||||
*/
|
*/
|
||||||
//% color=#5C2D91 weight=31
|
//% color=#5C2D91 weight=31
|
||||||
|
//% advanced=true
|
||||||
namespace images {
|
namespace images {
|
||||||
/**
|
/**
|
||||||
* Creates an image that fits on the LED screen.
|
* Creates an image that fits on the LED screen.
|
@ -159,6 +159,7 @@ namespace input {
|
|||||||
*/
|
*/
|
||||||
//% help=input/on-pin-released weight=6 blockGap=8
|
//% help=input/on-pin-released weight=6 blockGap=8
|
||||||
//% blockId=device_pin_released block="on pin %NAME|released" icon="\uf094"
|
//% blockId=device_pin_released block="on pin %NAME|released" icon="\uf094"
|
||||||
|
//% advanced=true
|
||||||
void onPinReleased(TouchPin name, Action body) {
|
void onPinReleased(TouchPin name, Action body) {
|
||||||
auto pin = getPin((int)name);
|
auto pin = getPin((int)name);
|
||||||
if (!pin) return;
|
if (!pin) return;
|
||||||
@ -171,7 +172,7 @@ namespace input {
|
|||||||
/**
|
/**
|
||||||
* Get the button state (pressed or not) for ``A`` and ``B``.
|
* Get the button state (pressed or not) for ``A`` and ``B``.
|
||||||
*/
|
*/
|
||||||
//% help=input/button-is-pressed weight=57
|
//% help=input/button-is-pressed weight=60
|
||||||
//% block="button|%NAME|is pressed"
|
//% block="button|%NAME|is pressed"
|
||||||
//% blockId=device_get_button2
|
//% blockId=device_get_button2
|
||||||
//% icon="\uf192" blockGap=8
|
//% icon="\uf192" blockGap=8
|
||||||
@ -190,7 +191,7 @@ namespace input {
|
|||||||
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
||||||
* @param name pin used to detect the touch
|
* @param name pin used to detect the touch
|
||||||
*/
|
*/
|
||||||
//% help=input/pin-is-pressed weight=56
|
//% help=input/pin-is-pressed weight=58
|
||||||
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094"
|
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094"
|
||||||
//% blockGap=8
|
//% blockGap=8
|
||||||
bool pinIsPressed(TouchPin name) {
|
bool pinIsPressed(TouchPin name) {
|
||||||
@ -198,6 +199,40 @@ namespace input {
|
|||||||
return pin && pin->isTouched();
|
return pin && pin->isTouched();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getAccelerationStrength() {
|
||||||
|
double x = uBit.accelerometer.getX();
|
||||||
|
double y = uBit.accelerometer.getY();
|
||||||
|
double z = uBit.accelerometer.getZ();
|
||||||
|
return (int)sqrt(x*x+y*y+z*z);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)
|
||||||
|
* @param dimension TODO
|
||||||
|
*/
|
||||||
|
//% help=input/acceleration weight=58 icon="\uf135"
|
||||||
|
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
|
||||||
|
//% parts="accelerometer"
|
||||||
|
int acceleration(Dimension dimension) {
|
||||||
|
switch (dimension) {
|
||||||
|
case Dimension::X: return uBit.accelerometer.getX();
|
||||||
|
case Dimension::Y: return uBit.accelerometer.getY();
|
||||||
|
case Dimension::Z: return uBit.accelerometer.getZ();
|
||||||
|
case Dimension::Strength: return getAccelerationStrength();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
|
||||||
|
*/
|
||||||
|
//% help=input/light-level weight=57
|
||||||
|
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185"
|
||||||
|
//% parts="ledmatrix"
|
||||||
|
int lightLevel() {
|
||||||
|
return uBit.display.readLightLevel();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current compass heading in degrees.
|
* Get the current compass heading in degrees.
|
||||||
*/
|
*/
|
||||||
@ -221,48 +256,13 @@ namespace input {
|
|||||||
return uBit.thermometer.getTemperature();
|
return uBit.thermometer.getTemperature();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getAccelerationStrength() {
|
|
||||||
double x = uBit.accelerometer.getX();
|
|
||||||
double y = uBit.accelerometer.getY();
|
|
||||||
double z = uBit.accelerometer.getZ();
|
|
||||||
return (int)sqrt(x*x+y*y+z*z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)
|
|
||||||
* @param dimension TODO
|
|
||||||
*/
|
|
||||||
//% help=input/acceleration weight=54 icon="\uf135"
|
|
||||||
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
|
|
||||||
//% parts="accelerometer"
|
|
||||||
int acceleration(Dimension dimension) {
|
|
||||||
switch (dimension) {
|
|
||||||
case Dimension::X: return uBit.accelerometer.getX();
|
|
||||||
case Dimension::Y: return uBit.accelerometer.getY();
|
|
||||||
case Dimension::Z: return uBit.accelerometer.getZ();
|
|
||||||
case Dimension::Strength: return getAccelerationStrength();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
|
|
||||||
*/
|
|
||||||
//% help=input/light-level weight=53
|
|
||||||
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185"
|
|
||||||
//% parts="ledmatrix"
|
|
||||||
int lightLevel() {
|
|
||||||
return uBit.display.readLightLevel();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees.
|
* The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees.
|
||||||
* @param kind TODO
|
* @param kind TODO
|
||||||
*/
|
*/
|
||||||
//% help=input/rotation weight=52
|
//% help=input/rotation weight=52
|
||||||
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197"
|
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197"
|
||||||
//% parts="accelerometer"
|
//% parts="accelerometer" advanced=true
|
||||||
int rotation(Rotation kind) {
|
int rotation(Rotation kind) {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case Rotation::Pitch: return uBit.accelerometer.getPitch();
|
case Rotation::Pitch: return uBit.accelerometer.getPitch();
|
||||||
@ -278,6 +278,7 @@ namespace input {
|
|||||||
//% help=input/magnetic-force weight=51
|
//% help=input/magnetic-force weight=51
|
||||||
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076"
|
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076"
|
||||||
//% parts="compass"
|
//% parts="compass"
|
||||||
|
//% advanced=true
|
||||||
int magneticForce(Dimension dimension) {
|
int magneticForce(Dimension dimension) {
|
||||||
if (!uBit.compass.isCalibrated())
|
if (!uBit.compass.isCalibrated())
|
||||||
uBit.compass.calibrate();
|
uBit.compass.calibrate();
|
||||||
@ -296,6 +297,7 @@ namespace input {
|
|||||||
*/
|
*/
|
||||||
//% help=input/running-time weight=50
|
//% help=input/running-time weight=50
|
||||||
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017"
|
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017"
|
||||||
|
//% advanced=true
|
||||||
int runningTime() {
|
int runningTime() {
|
||||||
return system_timer_current_time();
|
return system_timer_current_time();
|
||||||
}
|
}
|
||||||
@ -314,6 +316,7 @@ namespace input {
|
|||||||
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
||||||
//% weight=5
|
//% weight=5
|
||||||
//% parts="accelerometer"
|
//% parts="accelerometer"
|
||||||
|
//% advanced=true
|
||||||
void setAccelerometerRange(AcceleratorRange range) {
|
void setAccelerometerRange(AcceleratorRange range) {
|
||||||
uBit.accelerometer.setRange((int)range);
|
uBit.accelerometer.setRange((int)range);
|
||||||
}
|
}
|
@ -54,6 +54,7 @@ namespace led {
|
|||||||
//% help=led/brightness weight=60
|
//% help=led/brightness weight=60
|
||||||
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8
|
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
|
//% advanced=true
|
||||||
int brightness() {
|
int brightness() {
|
||||||
return uBit.display.getBrightness();
|
return uBit.display.getBrightness();
|
||||||
}
|
}
|
||||||
@ -65,6 +66,7 @@ namespace led {
|
|||||||
//% help=led/set-brightness weight=59
|
//% help=led/set-brightness weight=59
|
||||||
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042"
|
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042"
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
|
//% advanced=true
|
||||||
void setBrightness(int value) {
|
void setBrightness(int value) {
|
||||||
uBit.display.setBrightness(value);
|
uBit.display.setBrightness(value);
|
||||||
}
|
}
|
||||||
@ -75,6 +77,7 @@ namespace led {
|
|||||||
//% weight=50 help=led/stop-animation
|
//% weight=50 help=led/stop-animation
|
||||||
//% blockId=device_stop_animation block="stop animation" icon="\uf04d"
|
//% blockId=device_stop_animation block="stop animation" icon="\uf04d"
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
|
//% advanced=true
|
||||||
void stopAnimation() {
|
void stopAnimation() {
|
||||||
uBit.display.stopAnimation();
|
uBit.display.stopAnimation();
|
||||||
}
|
}
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |