Compare commits
115 Commits
Author | SHA1 | Date | |
---|---|---|---|
135aaf4855 | |||
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 | |||
2c39e249f9 | |||
c486a9db94 | |||
816438fa79 | |||
5edd06c9b9 | |||
a114dc32e7 | |||
019bc34d90 | |||
0676d780ab | |||
96e23d99b2 | |||
15b1f95394 | |||
552b0d8165 | |||
faed492a87 | |||
0ce1738653 |
@ -9,7 +9,7 @@ script:
|
||||
- "(cd libs/lang-test1; node ../../node_modules/pxt-core/built/pxt.js test)"
|
||||
- "node node_modules/pxt-core/built/pxt.js testdir tests"
|
||||
- "node node_modules/pxt-core/built/pxt.js uploaddoc"
|
||||
- "(cd libs/hello; node ../../node_modules/pxt-core/built/pxt.js testconv https://az851932.vo.msecnd.net/files/td-converter-tests-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
|
||||
notifications:
|
||||
email:
|
||||
|
3
.vscode/settings.json
vendored
@ -16,5 +16,6 @@
|
||||
"**/pxt_modules/**": 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()
|
||||
.then(drives => {
|
||||
if (drives.length == 0) {
|
||||
console.log("cannot find any drives to deploy to")
|
||||
} else {
|
||||
console.log(`copy ${ts.pxtc.BINARY_HEX} to ` + drives.join(", "))
|
||||
console.log("cannot find any drives to deploy to");
|
||||
return Promise.resolve(0);
|
||||
}
|
||||
return Promise.map(drives, d =>
|
||||
writeFileAsync(d + ts.pxtc.BINARY_HEX, res.outfiles[ts.pxtc.BINARY_HEX])
|
||||
.then(() => {
|
||||
console.log("wrote hex file to " + d)
|
||||
}))
|
||||
})
|
||||
.then(() => { })
|
||||
|
||||
console.log(`copy ${ts.pxtc.BINARY_HEX} to ` + drives.join(", "));
|
||||
|
||||
let writeHexFile = (filename: string) => {
|
||||
return writeFileAsync(filename + ts.pxtc.BINARY_HEX, res.outfiles[ts.pxtc.BINARY_HEX])
|
||||
.then(() => console.log("wrote hex file to " + filename));
|
||||
};
|
||||
|
||||
return Promise.map(drives, d => writeHexFile(d))
|
||||
.then(() => drives.length);
|
||||
});
|
||||
}
|
||||
|
||||
function getBitDrivesAsync(): Promise<string[]> {
|
||||
|
@ -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">
|
||||
(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||[]);
|
||||
|
||||
mixpanel.init("762fef19c053a0ea4cec43d2fecae76e");
|
||||
mixpanel.init("762fef19c053a0ea4cec43d2fecae76e", { disable_persistence: true });
|
||||
if (typeof pxtConfig !== "undefined") mixpanel.register({ target: pxtConfig.targetId, version: pxtConfig.targetVersion });
|
||||
</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">
|
||||
(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||[]);
|
||||
|
||||
mixpanel.init("762fef19c053a0ea4cec43d2fecae76e");
|
||||
mixpanel.init("762fef19c053a0ea4cec43d2fecae76e", { disable_persistence: true });
|
||||
if (typeof pxtConfig !== "undefined") mixpanel.register({ target: pxtConfig.targetId, version: pxtConfig.targetVersion });
|
||||
</script>
|
||||
|
@ -3,8 +3,6 @@
|
||||
As you are using a Mac, it is recommended that you use [Safari][]. Alternatively,
|
||||
[Google Chrome][chrome] and [Mozilla Firefox][firefox] are also supported.
|
||||
|
||||
You cannot use Safari in private browsing mode when using the editor.
|
||||
|
||||
Please see [here][technical] for technical information on which browsers are
|
||||
supported, or [here][versions] to check which version you are using.
|
||||
|
||||
|
@ -1,11 +1,40 @@
|
||||
# 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`.
|
||||
The large holes at the bottom of the board are designed to attach alligator/crocodile clips
|
||||
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
|
||||
input.onPinPressed(TouchPin.P0, () => {
|
||||
@ -13,11 +42,6 @@ input.onPinPressed(TouchPin.P0, () => {
|
||||
})
|
||||
```
|
||||
|
||||
### Connecting Crocodile Clips
|
||||
|
||||

|
||||
|
||||
### 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)
|
||||
## See also
|
||||
|
||||
[micro:bit pins](/device/pins)
|
||||
|
@ -1,7 +1,5 @@
|
||||
# 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.
|
||||
|
||||
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
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
## Objectives
|
||||
|
||||
|
@ -7,7 +7,7 @@ Have you ever tried to play a song on an instrument? Let's try coding the song "
|
||||
Let's start by adding the code in the music drawer that includes a single musical chord (or pitched sound) with the `play` block. Then insert the chord "C". Once you are done coding, don't forget to run your code in the simulator or the micro:bit.
|
||||
|
||||
```blocks
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
```
|
||||
|
||||
* click run to see if the code works as expected.
|
||||
@ -15,12 +15,12 @@ music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
We want to continue to adding musical chords with the `play` block. So insert the appropriate chord blocks: `D`, `F`, `G` to complete the first part of the song. Modify your code so that your code looks like this.
|
||||
|
||||
```blocks
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quarter));
|
||||
basic.pause(100);
|
||||
```
|
||||
|
||||
@ -29,19 +29,19 @@ basic.pause(100);
|
||||
We want to continue to adding musical chords with the `play` block. Then insert the appropriate chords: `B`, `C`, `D`, `E` , `F` to complete the second part of the song. Modify your code so that your code looks like this.
|
||||
|
||||
```blocks
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quarter));
|
||||
basic.pause(100);
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.G), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.G), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
|
||||
basic.pause(100);
|
||||
```
|
||||
|
||||
|
@ -8,19 +8,19 @@ Complete the [happy birthday](/lessons/happy-birthday/activity) activity and you
|
||||
|
||||
|
||||
```blocks
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quarter));
|
||||
basic.pause(100);
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.G), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.G), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
|
||||
basic.pause(100);
|
||||
|
||||
|
||||
@ -35,26 +35,26 @@ Let's code the third part of Happy Birthday!
|
||||
To do this, you need to add blocks after the last line of the `play` blocks. We want to continue to adding musical chords with the `play` block. Then insert the appropriate chord blocks `G`, `E`, `C`, `B`, `A` to complete the third part of the song. Modify your code so that your code looks like this.
|
||||
|
||||
```blocks
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quarter));
|
||||
basic.pause(100);
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.G), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.G), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
|
||||
basic.pause(100);
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.A), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.A), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quarter));
|
||||
basic.pause(100);
|
||||
```
|
||||
|
||||
@ -66,33 +66,33 @@ Finally, we continue to adding the appropriate `play` block and fit the followin
|
||||
|
||||
|
||||
```blocks
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quarter));
|
||||
basic.pause(100);
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.G), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.G), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
|
||||
basic.pause(100);
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.A), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.A), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.E), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.D), music.beat(BeatFraction.Quarter));
|
||||
basic.pause(100);
|
||||
music.playTone(music.noteFrequency(Note.A), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.A), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.B), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.G), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quater));
|
||||
music.playTone(music.noteFrequency(Note.A), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.A), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.B), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.G), music.beat(BeatFraction.Quarter));
|
||||
music.playTone(music.noteFrequency(Note.F), music.beat(BeatFraction.Quarter));
|
||||
```
|
||||
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
# hero
|
||||
|
||||
make a game to test hand-eye coordination.
|
||||
|
||||
Make a game to test hand-eye coordination
|
||||
|
||||
* [activity](/lessons/hero/activity)
|
||||
|
@ -2,6 +2,9 @@
|
||||
|
||||
Here are some cool projects that you can build with your micro:bit!
|
||||
|
||||
## Games
|
||||
|
||||
Fun games to build with your micro:bit.
|
||||
|
||||
```codecard
|
||||
[{
|
||||
@ -20,11 +23,13 @@ Here are some cool projects that you can build with your micro:bit!
|
||||
"name": "Rock Paper Scissors",
|
||||
"url":"/projects/rock-paper-scissors",
|
||||
"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",
|
||||
"url":"/projects/hack-your-headphones",
|
||||
"imageUrl":"/static/mb/projects/a6-music.png"
|
||||
@ -32,6 +37,28 @@ Here are some cool projects that you can build with your micro:bit!
|
||||
"name": "Banana keyboard",
|
||||
"url":"/projects/banana-keyboard",
|
||||
"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",
|
||||
"url":"/projects/telegraph",
|
||||
@ -40,13 +67,9 @@ Here are some cool projects that you can build with your micro:bit!
|
||||
"name": "Radio",
|
||||
"url":"/projects/radio",
|
||||
"imageUrl":"/static/mb/projects/a9-radio.png"
|
||||
},{
|
||||
"name": "Watch",
|
||||
"url":"/projects/the-watch",
|
||||
"imageUrl":"/static/mb/projects/a10-watch.png"
|
||||
}]
|
||||
```
|
||||
|
||||
### 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
|
||||
|
||||
@ -15,86 +19,11 @@ In this project, you will build your own music player micro:bit banana keyboard
|
||||
* Orange
|
||||
* Crocodile clips
|
||||
|
||||
## Steps
|
||||
## Activities
|
||||
|
||||
### 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
|
||||
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)!
|
||||
* [Making the keyboard](/projects/banana-keyboard/making)
|
||||
* [Beat box](/projects/banana-keyboard/beat-box)
|
||||
|
||||
### ~button /projects/banana-keyboard/making
|
||||
Let's get started!
|
||||
### ~
|
||||
|
@ -1,10 +1,4 @@
|
||||
# banana keyboard blocks challenges
|
||||
|
||||
control images with variables.
|
||||
|
||||
## Before we get started
|
||||
|
||||
Control images with variables.
|
||||
# banana keyboard - beat box
|
||||
|
||||
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.
|
||||
|
||||
### ~button /projects/telegraph
|
||||
NEXT: Telegraph
|
||||
### ~
|
||||
* click *Download* to see if the code works as expected.
|
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
|
||||
### ~
|
@ -11,7 +11,8 @@ basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .`);
|
||||
. . # . .`
|
||||
);
|
||||
basic.pause(500);
|
||||
basic.clearScreen();
|
||||
basic.pause(500);
|
||||
@ -33,7 +34,8 @@ basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .`);
|
||||
. . # . .`
|
||||
);
|
||||
```
|
||||
|
||||
## Step 2
|
||||
@ -62,7 +64,8 @@ basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .`);
|
||||
. . # . .`
|
||||
);
|
||||
basic.pause(500);
|
||||
basic.clearScreen();
|
||||
})
|
||||
@ -79,7 +82,8 @@ basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .`);
|
||||
. . # . .`
|
||||
);
|
||||
basic.pause(500);
|
||||
basic.clearScreen();
|
||||
basic.pause(500);
|
||||
@ -98,7 +102,8 @@ basic.showLeds(`
|
||||
# # # # #
|
||||
# # # # #
|
||||
. # # # .
|
||||
. . # . .`);
|
||||
. . # . .`
|
||||
);
|
||||
basic.pause(500);
|
||||
basic.clearScreen();
|
||||
basic.pause(500);
|
||||
@ -107,13 +112,10 @@ basic.showLeds(`
|
||||
# . # # #
|
||||
# . . . #
|
||||
. # # # .
|
||||
. . # . .`);
|
||||
. . # . .`
|
||||
);
|
||||
basic.pause(500);
|
||||
basic.clearScreen();
|
||||
basic.pause(500);
|
||||
})
|
||||
```
|
||||
|
||||
### ~button /projects/smiley-buttons
|
||||
NEXT: Smiley Buttons
|
||||
### ~
|
42
docs/projects/guitar.md
Normal file
@ -0,0 +1,42 @@
|
||||
# Guitar
|
||||
|
||||

|
||||
|
||||
### @description A beginner-intermediate maker activity, building a guitar with the micro:bit
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Make a micro:bit guitar with this guided tutorial!
|
||||
|
||||
### ~
|
||||
*playing micro:bit guitar*
|
||||
https://youtu.be/GYmdTFvxz80
|
||||
|
||||
## Duration
|
||||
|
||||
5 Activities, approx 30-45 min each based on familiarity with the coding concepts
|
||||
|
||||
## Materials
|
||||
|
||||
* Cardboard large pieces (recycle!)
|
||||
* Tape (masking, duct tape, and/or packing tape)
|
||||
* Markers and/or paint
|
||||
* Aluminum Foil
|
||||
* Scissors that can cut cardboard
|
||||
* 1 micro:bit, battery holder and 2 AAA batteries
|
||||
* 4-5 Crocodile clips
|
||||
* Headphones
|
||||
|
||||
## Activities
|
||||
|
||||
* [Making the Guitar Body](/projects/guitar/making)
|
||||
* [Buttons, Display & Sound](/projects/guitar/displaybuttons)
|
||||
* [Light Sensor Tone control](/projects/guitar/lightsensor)
|
||||
* [Accelerometer Beat control](/projects/guitar/accelerometer)
|
||||
* [Pin Press Switch](/projects/guitar/pinpress)
|
||||
|
||||
### ~button /projects/guitar/making
|
||||
|
||||
Let's get started!
|
||||
|
||||
### ~
|
115
docs/projects/guitar/accelerometer.md
Normal file
@ -0,0 +1,115 @@
|
||||
# Accelerometer Beat control
|
||||
|
||||
### @description micro:bit guitar: using accelerometer to control tempo
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Use the Accelerometer to control guitar tempo
|
||||
* Concepts:
|
||||
* Gravity
|
||||
* Acceleration
|
||||
* X, Y, Z coordinates
|
||||
* Tempo
|
||||
* Beat
|
||||
* Mapping
|
||||
* Graphing
|
||||
* Absolute value
|
||||
|
||||
### ~
|
||||
|
||||
## Duration: 30 - 45 minutes
|
||||
|
||||
*accelerometer controlled tempo*
|
||||
https://youtu.be/kA0HpqCWsjs
|
||||
|
||||
## Blocks
|
||||
|
||||
```cards
|
||||
input.acceleration(Dimension.Y)
|
||||
music.setTempo(120)
|
||||
pins.map(0, 0, 1023,60, 320)
|
||||
Math.abs(1)
|
||||
```
|
||||
|
||||
## Accelerometer, gravity and tilting!
|
||||
|
||||
The micro:bit contains an **accelerometer** sensor that is able to measure forces applied to the board.
|
||||
On earth, we are subject to the **gravity force** which pulls us to the ground!
|
||||
|
||||
https://youtu.be/0SULoTKmkhI
|
||||
|
||||
When the micro:bit is flat on a table, with the screen pointing up, the gravity force is aligned
|
||||
with the **Z** axis of the micro:bit.
|
||||
|
||||

|
||||
|
||||
If you tilt it up and down, the force will align with the **Y** axis -- this is how we can detect tilting!!!
|
||||
If the force along **Y** grows, the micro:bit is tilting more and more vertically!
|
||||
|
||||
## Measuring Acceleration along different coordinates (X, Y, Z axis)
|
||||
|
||||
The acceleration block approximately measures **milli-g**, which is 1/1000 of a **g** or the
|
||||
acceleration of gravity.
|
||||
|
||||
### Step 1: Graphing acceleration
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
led.plotBarGraph(input.acceleration(Dimension.Y), 1023)
|
||||
})
|
||||
```
|
||||
**Create the code** that measures the change in the Y axis acceleration as a graph on the LEDs
|
||||
|
||||
**Dowload the code** to the micro:bit
|
||||
|
||||
**Test the movements that move the graph from 1 to 5 bars on the LEDs**
|
||||
|
||||
### Extra
|
||||
|
||||
Try graphing the acceleration along the **X** and **Z** axis. Can you explain the differences?
|
||||
|
||||
### ~hint
|
||||
## Mapping
|
||||
**It is common to map one standard to another - such as with temperature**
|
||||

|
||||
### ~
|
||||
|
||||
### Step 2: Mapping acceleration to Beat
|
||||
**micro:bit sensors produce signal values between 0 to 1023. The *[map block](/reference/pins/map)* converts the signal to a desired range.**
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
music.setTempo(pins.map(Math.abs(input.acceleration(Dimension.Y)),
|
||||
0, 1023,
|
||||
60, 320))
|
||||
music.playTone(Note.C, music.beat(BeatFraction.Quarter));
|
||||
})
|
||||
```
|
||||
|
||||
**Create the code** that *Maps* Y axis acceleration as *tempo*
|
||||
|
||||
**Download the code** to the micro:bit on the guitar
|
||||
|
||||
**Test the movements that speed and slow the tempo**
|
||||
|
||||
### Step 3: Combine with light sensor tone control
|
||||
**Put it all together!**
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
music.setTempo(pins.map(Math.abs(input.acceleration(Dimension.Y)),
|
||||
0, 1023,
|
||||
60, 320))
|
||||
music.playTone(
|
||||
input.lightLevel() * 25,
|
||||
music.beat(BeatFraction.Quarter)
|
||||
);
|
||||
})
|
||||
```
|
||||
**Combine the code above with the light sensor tone control code from the previous activity**
|
||||
|
||||
**Download the code** to the micro:bit on the guitar
|
||||
|
||||
### Now play the guitar adjusting tone and tempo using the light sensor and accelerometer!
|
||||
|
||||
### ~button /projects/guitar/pinpress
|
||||
NEXT: Pin Press on/off
|
||||
### ~
|
179
docs/projects/guitar/displaybuttons.md
Normal file
@ -0,0 +1,179 @@
|
||||
# Buttons, Display & Sound
|
||||
### @description micro:bit guitar: using buttons with display and sound
|
||||
|
||||
### ~avatar avatar
|
||||
Use Button Events to control LED Display and play Sound
|
||||
* **Concepts:**
|
||||
* Events
|
||||
* Tone/Note
|
||||
* Sequence
|
||||
|
||||
### ~
|
||||
|
||||
## Duration: 30 - 45 minutes
|
||||
|
||||
## Materials
|
||||
|
||||
A micro:bit, battery pack and 2 x AAA batteries
|
||||
|
||||

|
||||
|
||||
2 to 4 crocodile clips
|
||||
|
||||

|
||||
|
||||
Headphones
|
||||
|
||||

|
||||
|
||||
## Blocks
|
||||
|
||||
```cards
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # # # .
|
||||
`);
|
||||
input.onButtonPressed(Button.A, () => {});
|
||||
music.playTone(Note.C, music.beat(BeatFraction.Quarter))
|
||||
music.rest(music.beat(BeatFraction.Whole))
|
||||
music.beat(BeatFraction.Quarter)
|
||||
```
|
||||
|
||||
## Step 1: Make a Smiley
|
||||
Open [codethemicrobit.com](https://codethemicrobit.com) in your web browser
|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # # # .
|
||||
`);
|
||||
```
|
||||
From **Basics**, drag a **show LEDs** block into the coding area
|
||||
* Create a face with LEDs
|
||||
|
||||

|
||||
Connect your micro:bit to your computer via USB and click **`Download`**.
|
||||
Follow the instructions to move the code to your micro:bit.
|
||||
|
||||
## Step 2: Add Smiley LED Button Events
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # # # .
|
||||
`)
|
||||
})
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. . . . .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
})
|
||||
```
|
||||
|
||||
From **Input**, drag an **on button 'A' pressed** block into the coding area
|
||||
|
||||
* Snap the LED face into the block
|
||||
|
||||
* Create a 'B' button block with a different LED face
|
||||
|
||||
* Download the code to your micro:bit and try the A & B buttons
|
||||
|
||||
|
||||
## Step 3: Add Headphone Speakers using Crocodile clips
|
||||
|
||||

|
||||
|
||||

|
||||
Connect **GND** to the **base of the headphone jack** using a second crocodile clip (usually black)
|
||||
|
||||
Connect **pin 0** to the **tip of the headphone jack** with a crocodile clip
|
||||
|
||||
*attaching batteries and micro:bit*
|
||||
https://youtu.be/zwRTmpKIaVU
|
||||
Attach the micro:bit & battery-pack to the guitar body
|
||||
|
||||
*connecting headphone speaker*
|
||||
https://youtu.be/ewyEW_U5G9M
|
||||
Connect the headphones with crocodile clips
|
||||
|
||||
### ~hint
|
||||
## The micro:bit can play music
|
||||
|
||||
The **play tone** block allows a range letter note tones from **C** to **B5**.
|
||||
Songs are played using sequences notes. Like the beginning of a birthday song (C, C, D, C, F, E).
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
music.playTone(Note.C, music.beat(BeatFraction.Quarter))
|
||||
music.rest(music.beat(BeatFraction.Whole))
|
||||
music.playTone(Note.C, music.beat(BeatFraction.Quarter))
|
||||
music.rest(music.beat(BeatFraction.Whole))
|
||||
music.playTone(Note.D, music.beat(BeatFraction.Quarter))
|
||||
music.rest(music.beat(BeatFraction.Whole))
|
||||
music.playTone(Note.C, music.beat(BeatFraction.Quarter))
|
||||
music.rest(music.beat(BeatFraction.Whole))
|
||||
music.rest(music.beat(BeatFraction.Whole))
|
||||
music.playTone(Note.F, music.beat(BeatFraction.Half))
|
||||
music.rest(music.beat(BeatFraction.Whole))
|
||||
music.playTone(Note.E, music.beat(BeatFraction.Whole))
|
||||
})
|
||||
```
|
||||
### ~
|
||||
## Step 4: Add Tone Playing Events for Buttons A & B
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # # # .
|
||||
. # . # .
|
||||
. # # # .
|
||||
`)
|
||||
music.playTone(Note.A, music.beat(BeatFraction.Whole))
|
||||
})
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. . . . .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
music.playTone(Note.G, music.beat(BeatFraction.Whole))
|
||||
})
|
||||
```
|
||||
From **Music**, drag **play tone *C* for *1* beat** block under the **show leds** in **Button A Pressed**
|
||||
|
||||
* modify **tone** by choosing a note (*letter*) and experiment with high and low pitches
|
||||
* set **beat** to 1
|
||||
|
||||
**Repeat** for **Button B** event
|
||||
|
||||
**Download the code** to the micro:bit
|
||||
|
||||
**Try the A & B buttons** with headphones and power connected
|
||||
|
||||
## Congratulations on completing the basic guitar!
|
||||
**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
|
||||
|
||||
## Extra
|
||||
|
||||
* [Smiley Buttons tutorial](/projects/smiley-buttons)
|
||||
* [Hack your headphones](/projects/hack-your-headphones)
|
||||
|
||||
|
||||
### ~button /projects/guitar/lightsensor
|
||||
NEXT: Light Sensor Tone Control
|
||||
### ~
|
115
docs/projects/guitar/lightsensor.md
Normal file
@ -0,0 +1,115 @@
|
||||
# Light Sensor Tone control
|
||||
|
||||
### @description micro:bit guitar: using light sensor to control tone
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Use the Light Sensor to the control tone for this [Theremin](https://en.wikipedia.org/wiki/Theremin) inspired guitar
|
||||
|
||||
* **Concepts:**
|
||||
* Inputs
|
||||
* Light Intensity
|
||||
* Tone/Frequency
|
||||
* Ratio Mapping
|
||||
* Forever Loop
|
||||
* Math (multiplication) with code properties
|
||||
### ~
|
||||
|
||||
## Duration: 30 - 45 minutes
|
||||
|
||||
*playing tones with light sensor*
|
||||
https://youtu.be/2cKg9pokVC4
|
||||
|
||||
## The micro:bit LEDs Light Sensors
|
||||
|
||||
- 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*)
|
||||
- a **Forever Loop** is required to continually measure the current light level and control the tone
|
||||
|
||||
## Forever Loop
|
||||
|
||||
The forever loop really does run forever. The forever loop is useful when there is a need to continually check for an event or use a changing value in code.
|
||||
|
||||
## Blocks
|
||||
|
||||
```cards
|
||||
basic.forever(() => {})
|
||||
input.lightLevel()
|
||||
led.plotBarGraph(0, 255)
|
||||
music.playTone(Note.C, music.beat(BeatFraction.Quarter))
|
||||
```
|
||||
|
||||
## Step 1: Create a light level detector
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
led.plotBarGraph(input.lightLevel(), 255)
|
||||
})
|
||||
```
|
||||
**Build the blocks**
|
||||
* From **Basic** drag a **forever loop** block into the coding area
|
||||
* From **Led** drag a **plot bar graph** block into the **forever loop**
|
||||
* From **Input** drag a **light level** block into **plot bar graph *of***
|
||||
|
||||
**Set the *plot bar graph* value *up to* = *255* **
|
||||
|
||||
## Step 2: Test the light required to move the bar graph height
|
||||
|
||||
*graphing light input*
|
||||
https://youtu.be/pqU7bTcfQ_s
|
||||
Experiment to see the effect on graph height when the **plot bar graph** value ***up to*** is changed
|
||||
|
||||
**255 is the maximum light input reading**, try numbers smaller than 255
|
||||
**Find a value** that allows the graph to show 1 - 5 bars
|
||||
|
||||
### ~hint
|
||||
### Frequency
|
||||
**Frequency** measured in Hz which are cycles per second or vibrations per second
|
||||
* A healthy human ear can detect frequencies in the range of 20Hz to 20,000Hz.
|
||||
* The micro:bit + headphones reliably produce detectable output ~50Hz - 6,000Hz.
|
||||
|
||||
**261Hz** represents a C note
|
||||
```blocks
|
||||
music.playTone(261, music.beat(BeatFraction.Half))
|
||||
```
|
||||
**play tone** blocks can specify a numeric **Frequency**
|
||||
by replacing the letter **C** note with a **number** block that has the value it represents
|
||||
```blocks
|
||||
music.playTone(261, music.beat(BeatFraction.Half))
|
||||
```
|
||||
### ~
|
||||
|
||||
## Step 3: Multiply Frequency using Math blocks
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
music.playTone(261 * 2, music.beat(BeatFraction.Half))
|
||||
})
|
||||
```
|
||||
Create a **play tone** block using a **Math** section, **multiplication** block to set *tone*
|
||||
|
||||
### Next
|
||||
**Add** a **B** button block that multiplies the **261** tone by a number other than 2 to set tone
|
||||
|
||||
**Download the code to the micro:bit**
|
||||
|
||||
**Test the sound for multiples of the 261Hz *C* frequency**
|
||||
|
||||
## Step 4: Control the Frequency with the light input
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
music.playTone(input.lightLevel() * 25, music.beat(BeatFraction.Quarter))
|
||||
})
|
||||
```
|
||||
**Create a *forever loop* containing a *play tone* block**
|
||||
|
||||
**Set *tone*, using *Math* multiplication block that multiplies *light level* input by 25**
|
||||
or experiment with multipliers larger and smaller than 25
|
||||
|
||||
**Test light tone control on the guitar**
|
||||
Cover the LEDs with your hand to vary light detected to control the tone
|
||||
|
||||
## Good work, this guitar is sounding good!
|
||||
**Challenge:** Create a variable for the light level multiplier that you can change using buttons (optional)
|
||||
|
||||
### ~button /projects/guitar/accelerometer
|
||||
NEXT: Accelerometer Beat control
|
||||
### ~
|
59
docs/projects/guitar/making.md
Normal file
@ -0,0 +1,59 @@
|
||||
# Making the Guitar Body
|
||||
### @description Maker Project for Guitar Body for micro:bit
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Make the Guitar Body for your micro:bit Guitar
|
||||
|
||||
### ~
|
||||
|
||||
## Duration: ~45 minutes
|
||||
|
||||
## Materials
|
||||
* Cardboard large pieces (recycle!)
|
||||
* Tape (masking, duct tape, and/or packing tape)
|
||||
* Scissors that can cut cardboard
|
||||
* Markers and/or paint
|
||||
|
||||

|
||||
|
||||
## Step 1: Design the body
|
||||
*tracing the guitar design*
|
||||
https://youtu.be/xMSrWaOZkFg
|
||||
|
||||
* Search for [Guitar Silhouette](https://www.bing.com/images/search?q=Guitar+Silhouettes) design ideas and customize
|
||||
the shape of your guitar
|
||||
* Trace the design on a flat piece of cardboard (40-80 cm is best)
|
||||
|
||||
### ~hint
|
||||
|
||||
* Avoid small details that are difficult to cut into cardboard
|
||||
* Unfolding a box gives longer pieces of cardboard and creases can be reinforced
|
||||
|
||||
### ~
|
||||
|
||||
## Step 2: Cut out the body
|
||||
*cutting the cardboard*
|
||||
https://youtu.be/aUQkrFoEank
|
||||
|
||||
|
||||
## Step 3: Personalize the Guitar
|
||||
|
||||
Create unique styles using tape, markers, paint and other available materials (*calling all artists!*)
|
||||
|
||||
*decorating the guitar*
|
||||
https://youtu.be/zNAZTJeSxY8
|
||||
|
||||
Everyone can come up with a unique design!
|
||||
|
||||

|
||||
|
||||
## Extra!
|
||||
*strengthening the guitar*
|
||||
https://youtu.be/q0GkQdJmxjE
|
||||
|
||||
Strengthen the guitar next with an angled cardboard strip (*optional*).
|
||||
|
||||
### ~button /projects/guitar/displaybuttons
|
||||
NEXT: Buttons, Display and Sound
|
||||
### ~
|
131
docs/projects/guitar/pinpress.md
Normal file
@ -0,0 +1,131 @@
|
||||
# Pin Press Switch
|
||||
|
||||
### @description micro:bit guitar: use pin press to toggle guitar play on/off
|
||||
|
||||
### ~avatar avatar
|
||||
Use pin press to switch guitar play on/off
|
||||
|
||||
* Concepts:
|
||||
* Circuit
|
||||
* Conductor
|
||||
* Variable/Global-Variable
|
||||
* Conditional: **`if`**, **`else`**
|
||||
* Boolean: **`True`/`False`**
|
||||
### ~
|
||||
|
||||
## Duration: approximately 45 minutes
|
||||
|
||||
## Materials:
|
||||
2-3 Crocodile clips
|
||||
|
||||
## Blocks
|
||||
|
||||
```cards
|
||||
var on = false
|
||||
on;
|
||||
if (on) { } else {}
|
||||
input.onPinPressed(TouchPin.P1, () => {})
|
||||
```
|
||||
|
||||
|
||||
|
||||
### ~hint
|
||||
## Circuits & Switches
|
||||
* **Circuits** need a power supply (battery), a resister (like a LED) & a conductor (metal, water, hand)
|
||||
* **Switches** turn electric power on by closing (completing) a circuit with a conductor so power can flow
|
||||
|
||||
**Metal foil and wires make excellent conductors**
|
||||
|
||||
**In this activity we use YOU to conduct electricity**
|
||||
**to close the circuit that switches the guitar ON and OFF!**
|
||||
### ~
|
||||
|
||||
## Step 1: Pin Press Test
|
||||
|
||||
```blocks
|
||||
input.onPinPressed(TouchPin.P0, () => {
|
||||
basic.showNumber(0)
|
||||
})
|
||||
input.onPinPressed(TouchPin.P1, () => {
|
||||
basic.showNumber(1)
|
||||
})
|
||||
input.onPinPressed(TouchPin.P2, () => {
|
||||
basic.showNumber(2)
|
||||
})
|
||||
```
|
||||
**Create the pin-press code**
|
||||
|
||||
**Download the code** on the micro:bit
|
||||
|
||||
https://youtu.be/PAIU-vHqyGU
|
||||
|
||||
**Hold the micro:bit touching The GND pin with one hand**
|
||||
**with the other hand alternately touch the 0, 1 and 2 pins**
|
||||
|
||||
### ~hint
|
||||
**The electric signal traveled from pins, between your hands to `GND` and the micro:bit detected the electric signal!**
|
||||
### ~
|
||||
|
||||
## Step 2: Installing conductive foil on the guitar
|
||||
https://youtu.be/NX0ECcpXFes
|
||||
**Add foil to the guitar body where it is easy to touch while playing**
|
||||
|
||||
**Connect the foil to `GND` using a crocodile clip**
|
||||
|
||||
https://youtu.be/YkymZGNmkrE
|
||||
**Add foil to the guitar neck**
|
||||
|
||||
**Connect the foil to `pin 1` using a crocodile clip**
|
||||
|
||||
## Step 3: Add a switch to turn the guitar ON and OFF
|
||||
**Using the `on` global variable we can switch the message on the micro:bit**
|
||||
**between ON and OFF**
|
||||
```blocks
|
||||
let on = false
|
||||
basic.forever(() => {
|
||||
if (on == true) {
|
||||
basic.showString("ON")
|
||||
} else {
|
||||
basic.showString("OFF")
|
||||
}
|
||||
})
|
||||
input.onPinPressed(TouchPin.P1, () => {
|
||||
if (on == true) {
|
||||
on = false
|
||||
} else {
|
||||
on = true
|
||||
}
|
||||
})
|
||||
```
|
||||
**Create the ON/OFF switch code**
|
||||
|
||||
**Download the code on the micro:bit**
|
||||
|
||||
**Test by touching `P1` to toggle the LED message between ON and OFF**
|
||||
|
||||
*Final code*
|
||||
TODO: do we want to use `on = !on;` or be more direct in flipping the switch? `on = true; on = false;`
|
||||
```blocks
|
||||
var on = false
|
||||
basic.forever(() => {
|
||||
if (on) {
|
||||
music.setTempo(pins.map(Math.abs(input.acceleration(Dimension.Y)),
|
||||
0, 1023,
|
||||
60, 320))
|
||||
music.playTone(
|
||||
input.lightLevel() * 25,
|
||||
music.beat(BeatFraction.Quarter)
|
||||
);
|
||||
} else {
|
||||
music.rest(music.beat())
|
||||
}
|
||||
})
|
||||
input.onPinPressed(TouchPin.P1, () => {
|
||||
on = !on;
|
||||
})
|
||||
```
|
||||
## Now Play!
|
||||
**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**
|
||||
|
||||
https://youtu.be/GYmdTFvxz80
|
@ -1,12 +1,17 @@
|
||||
# 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
|
||||
|
||||
@ -14,48 +19,19 @@ In this project, you will build your own music player micro:bit from headphones.
|
||||
* Headphones
|
||||
* 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
|
||||
|
||||

|
||||
|
||||
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)!
|
||||
Let's get started!
|
||||
|
||||
### ~
|
||||
|
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
|
||||
|
||||
Control sound with the light level.
|
||||
# hack your headphones - music of light
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
@ -70,7 +68,3 @@ input.onButtonPressed(Button.A, () => {
|
||||
```
|
||||
|
||||
* 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
|
||||
* 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
|
||||
microbit-radio
|
||||
```
|
||||
|
@ -236,6 +236,3 @@ input.onButtonPressed(Button.B, () => {
|
||||
How else can you make your game better?
|
||||
Ever hear of [Rock Paper Scissors Spock Lizard](http://www.samkass.com/theories/RPSSL.html)?
|
||||
|
||||
### ~button /projects/compass
|
||||
NEXT: Compass
|
||||
### ~
|
@ -14,7 +14,8 @@ basic.showLeds(`
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .`);
|
||||
. # # # .`
|
||||
);
|
||||
```
|
||||
|
||||
## Step 2
|
||||
@ -28,14 +29,16 @@ basic.showLeds(`
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .`);
|
||||
. # # # .`
|
||||
);
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # # # .
|
||||
# . . . #`);
|
||||
# . . . #`
|
||||
);
|
||||
});
|
||||
```
|
||||
|
||||
@ -49,14 +52,16 @@ basic.showLeds(`
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .`);
|
||||
. # # # .`
|
||||
);
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # # # .
|
||||
# . . . #`);
|
||||
# . . . #`
|
||||
);
|
||||
});
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
basic.showLeds(`
|
||||
@ -64,10 +69,7 @@ input.onButtonPressed(Button.B, () => {
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .`);
|
||||
. # # # .`
|
||||
);
|
||||
});
|
||||
```
|
||||
|
||||
### ~button /projects/love-meter
|
||||
NEXT: Love Meter
|
||||
### ~
|
@ -1,75 +1,25 @@
|
||||
# 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
|
||||
|
||||
* micro:bit, battery holder and 2 AAA batteries
|
||||
* Crocodile clips
|
||||
|
||||
## Steps
|
||||
## Activities
|
||||
|
||||
### 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
|
||||
|
||||

|
||||
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/projects/telegraph-challenges)!
|
||||
* [Making the circuit](/projects/telegraph/making)
|
||||
* [Manual telegraph](/projects/telegraph/manual-telegraph)
|
||||
|
||||
### ~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.
|
||||
|
||||
# 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:
|
||||
|
||||

|
||||
Let's build the code that will send a impulse while the user presses ``A``.
|
||||
|
||||
### 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
|
||||
pins.digitalWritePin(DigitalPin.P0, 1)
|
||||
@ -21,7 +13,8 @@ pins.digitalWritePin(DigitalPin.P0, 1)
|
||||
|
||||
### 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
|
||||
pins.digitalWritePin(DigitalPin.P0, 1)
|
||||
@ -31,7 +24,8 @@ led.plot(2, 2)
|
||||
|
||||
### 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
|
||||
if (input.buttonIsPressed(Button.A)) {
|
||||
@ -45,7 +39,7 @@ if (input.buttonIsPressed(Button.A)) {
|
||||
|
||||
### 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
|
||||
if (input.buttonIsPressed(Button.A)) {
|
||||
@ -53,7 +47,7 @@ if (input.buttonIsPressed(Button.A)) {
|
||||
led.plot(2, 2)
|
||||
} else {
|
||||
pins.digitalWritePin(DigitalPin.P0, 0)
|
||||
basic.clearScreen()
|
||||
led.unplot(2, 2)
|
||||
}
|
||||
```
|
||||
|
||||
@ -68,23 +62,20 @@ basic.forever(() => {
|
||||
led.plot(2, 2)
|
||||
} else {
|
||||
pins.digitalWritePin(DigitalPin.P0, 0)
|
||||
basic.clearScreen()
|
||||
}
|
||||
led.unplot(2, 2)
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
### 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:
|
||||
|
||||
```blocks
|
||||
if (pins.digitalReadPin(DigitalPin.P1) == 1) {
|
||||
led.plot(2, 2);
|
||||
led.plot(4, 4);
|
||||
}
|
||||
else {
|
||||
basic.clearScreen();
|
||||
led.unplot(4, 4);
|
||||
}
|
||||
basic.forever(() => {
|
||||
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 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!
|
||||
|
||||
### ~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
|
||||
|
||||
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
|
||||
|
||||
The web editor requires to install IceWeasel (Firefox) as the built-in browser cannot handle it.
|
||||
|
||||
```
|
||||
sudo apt-get install iceweasel
|
||||
```
|
||||
|
||||
Once installed simply navigate to https://codethemicrobit.com or type
|
||||
|
||||
```
|
||||
firefox https://codethemicrobit.com
|
||||
```
|
||||
Starting with **Raspbian Pixel**, Raspbian comes with Chromium. Simply open [](https://codethemicrobit.com).
|
||||
|
||||
## Command line
|
||||
|
||||
|
@ -10,6 +10,10 @@ input.onButtonPressed(Button.A, () => {
|
||||
music.playTone(0, 0);
|
||||
led.plot(0, 0);
|
||||
radio.sendNumber(0);
|
||||
```
|
||||
## Advanced
|
||||
|
||||
```namespaces
|
||||
game.addScore(1);
|
||||
images.createImage(`
|
||||
. . . . .
|
||||
@ -24,7 +28,8 @@ control.inBackground(() => {
|
||||
|
||||
});
|
||||
```
|
||||
## Advanced
|
||||
|
||||
## Bluetooth
|
||||
|
||||
```namespaces
|
||||
devices.tellCameraTo(MesCameraEvent.TakePhoto);
|
||||
|
@ -1,27 +1,88 @@
|
||||
# Sharing your project
|
||||
|
||||
Once you have a cool project, it is possible to save it in the cloud and share it or embed it to your web site.
|
||||
Once you've made your project, you can save it the cloud, share it, or embed it on another website.
|
||||
|
||||
### Instructions
|
||||
* Click **More...**, then **Embed Project**:
|
||||
|
||||
* Click on **More...** then click **Embed Project...**
|
||||
* Click on the **Publish** button
|
||||

|
||||
|
||||
The embed dialog will provide you with various options to embed your project in your web site.
|
||||
* Click **Publish project**. This will make the project publicly available
|
||||
* You will then see this information:
|
||||
|
||||
### Project URL
|
||||

|
||||
|
||||
This URL will point to a web page that contains that project.
|
||||
## Sharing the URL
|
||||
|
||||
* see the "happy" project: https://codethemicrobit.com/pyirlbpsei
|
||||
You can share the URL for the project ([https://codethemicrobit.com/httuftrbtg](https://codethemicrobit.com/httuftrbtg) above) with other people, and they will be able to visit that page to see your project, download it, or edit it:
|
||||
|
||||
### Embedding into a blog or web site
|
||||

|
||||
|
||||
* Copy the HTML and paste it into your HTML source.
|
||||
## Embedding into a blog or web site
|
||||
|
||||
Rather than just sharing the link, you can also embed the project so that your visitors can use the simulator, edit blocks or code, or download the project without having to leave your site.
|
||||
|
||||
### General instructions
|
||||
|
||||
Select the kind of embedding you would like.
|
||||
|
||||
* **Screenshot** - a lightweight screenshot of the blocks that links to the snippet
|
||||
* **Editor** - embedded editor with minimal UI
|
||||
* **Simulator** - embedded simulator only
|
||||
* **Command line** - specific instructions to unpack the project using the [command line](/cli) tools
|
||||
|
||||
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.com][] blogs do not support embedding content from most websites, so you will need to link to your project instead. Alternatively, if you have a Wordpress VIP account you can follow [these instructions][wordpress-vip] to embed an `iframe` into your blog. The URL that you need to add is like `https://codethemicrobit.com/?sandbox=1#pub:httuftrbtg`, but replace `httuftrbtg` with your project's unique identifier.
|
||||
|
||||
If you self host a Wordpress blog you can install the [iframe-plugin][] and then write the following in your blog-post (again, replacing the `httuftrbtg` with your project's identifier):
|
||||
|
||||
```
|
||||
[iframe src="https://codethemicrobit.com/?sandbox=1#pub:httuftrbtg"]
|
||||
```
|
||||
|
||||
### Blogger
|
||||
|
||||
* Create a new post
|
||||
* Click the 'HTML' button next to 'Compose' and paste in the HTML
|
||||
|
||||

|
||||
|
||||
### Squarespace
|
||||
|
||||
[Squarespace][] allows you to embed HTML code inside a blog post or page. In the editor, click to add a new block:
|
||||
|
||||

|
||||
|
||||
Scroll to **More** and select **Code**. Paste the embed HTML and click **Apply**:
|
||||
|
||||

|
||||
|
||||
### Google Sites
|
||||
|
||||
Google Sites doesn't currently [support iframes in custom HTML][google-sites-iframes], so you'll have to insert a link to your project's URL instead.
|
||||
|
||||
### Office Sway
|
||||
|
||||
[Microsoft Office Sway][sway] only allows iframes from [certain websites][sway-restricted], so you'll need to insert a link to your project instead.
|
||||
### Embedding in Markdown documents
|
||||
|
||||
[Markdown][] is a popular text format supported by many blog editors. As Markdown supports embedded HTML, you should be able to paste the HTML into the document, although some sites may prevent you from doing this.
|
||||
|
||||
### ~hint
|
||||
|
||||
**Developers:** This page supports OEmbed as well
|
||||
|
||||
### ~
|
||||
|
||||
[wordpress.com]: https://wordpress.com
|
||||
[wordpress-vip]: https://vip.wordpress.com/documentation/embedding-rich-media-from-around-the-web-with-protected-embeds/#scripts-iframes-and-objects
|
||||
[iframe-plugin]: https://wordpress.org/plugins/iframe/
|
||||
[squarespace]: https://squarespace.com
|
||||
[google-sites-iframes]: https://support.google.com/sites/answer/2500646?hl=en
|
||||
[sway]: https://sway.com/my
|
||||
[sway-restricted]: https://support.office.com/en-us/article/Embed-content-in-your-Sway-1e1ab12a-f961-4a26-8afc-77a15f892b1d
|
||||
[Markdown]: https://daringfireball.net/projects/markdown/
|
BIN
docs/static/embed/blogger.png
vendored
Normal file
After Width: | Height: | Size: 101 KiB |
BIN
docs/static/embed/embed-info.png
vendored
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
docs/static/embed/project-page.png
vendored
Normal file
After Width: | Height: | Size: 207 KiB |
BIN
docs/static/embed/publish.png
vendored
Normal file
After Width: | Height: | Size: 54 KiB |
BIN
docs/static/embed/squarespace-code.png
vendored
Normal file
After Width: | Height: | Size: 81 KiB |
BIN
docs/static/embed/squarespace-insert.png
vendored
Normal file
After Width: | Height: | Size: 59 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/guitar.png
vendored
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
docs/static/mb/projects/guitar/accelleration_axis.png
vendored
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
docs/static/mb/projects/guitar/connectmicrobit.jpg
vendored
Normal file
After Width: | Height: | Size: 67 KiB |
BIN
docs/static/mb/projects/guitar/crocclipintoboard.jpg
vendored
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
docs/static/mb/projects/guitar/crocclips.jpg
vendored
Normal file
After Width: | Height: | Size: 59 KiB |
BIN
docs/static/mb/projects/guitar/headphones.jpg
vendored
Normal file
After Width: | Height: | Size: 71 KiB |
BIN
docs/static/mb/projects/guitar/jacktocrocs.jpg
vendored
Normal file
After Width: | Height: | Size: 86 KiB |
BIN
docs/static/mb/projects/guitar/map_analogy.png
vendored
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
docs/static/mb/projects/guitar/mapanalogy.JPG
vendored
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
docs/static/mb/projects/guitar/materials.jpg
vendored
Normal file
After Width: | Height: | Size: 94 KiB |
BIN
docs/static/mb/projects/guitar/microbit.jpg
vendored
Normal file
After Width: | Height: | Size: 102 KiB |
BIN
docs/static/mb/projects/guitar/otherdesigns.jpg
vendored
Normal file
After Width: | Height: | Size: 92 KiB |
BIN
docs/static/mb/projects/guitar/usbcable.jpg
vendored
Normal file
After Width: | Height: | Size: 51 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",
|
||||
"files": [
|
||||
"README.md",
|
||||
@ -10,7 +10,7 @@
|
||||
],
|
||||
"public": true,
|
||||
"dependencies": {
|
||||
"microbit": "file:../microbit"
|
||||
"core": "file:../core"
|
||||
},
|
||||
"yotta": {
|
||||
"config": {
|
@ -41,14 +41,14 @@
|
||||
"input.acceleration|param|dimension": "TODO",
|
||||
"input.buttonIsPressed": "Get the button state (pressed or not) for ``A`` and ``B``.",
|
||||
"input.calibrate": "Obsolete, compass calibration is automatic.",
|
||||
"input.compassHeading": "Get the current compass compass heading in degrees.",
|
||||
"input.compassHeading": "Get the current compass heading in degrees.",
|
||||
"input.lightLevel": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.",
|
||||
"input.magneticForce": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.",
|
||||
"input.magneticForce|param|dimension": "TODO",
|
||||
"input.onButtonPressed": "Do something when a button (``A``, ``B`` or both ``A+B``) is pressed",
|
||||
"input.onButtonPressed|param|body": "TODO",
|
||||
"input.onButtonPressed|param|button": "TODO",
|
||||
"input.onGesture": "Attaches code to run when the screen is facing up.",
|
||||
"input.onGesture": "Do something when when a gesture is done (like shaking the micro:bit).",
|
||||
"input.onGesture|param|body": "TODO",
|
||||
"input.onLogoDown": "Attaches code to run when the logo is oriented downwards and the board is vertical.",
|
||||
"input.onLogoDown|param|body": "TODO",
|
||||
@ -68,7 +68,7 @@
|
||||
"input.onShake|param|body": "TODO",
|
||||
"input.pinIsPressed": "Get the pin state (pressed or not). Requires to hold the ground to close the circuit.",
|
||||
"input.pinIsPressed|param|name": "pin used to detect the touch",
|
||||
"input.rotation": "The pitch of the device, rotation along the ``x-axis``, in degrees.",
|
||||
"input.rotation": "The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees.",
|
||||
"input.rotation|param|kind": "TODO",
|
||||
"input.runningTime": "Gets the number of milliseconds elapsed since power on.",
|
||||
"input.setAccelerometerRange": "Sets the accelerometer sample range in gravities.",
|