Compare commits

...

371 Commits

Author SHA1 Message Date
3f626105cd 0.5.24 2016-10-18 21:07:02 -07:00
d9ff9c4800 Bump pxt-core to 0.4.65 2016-10-18 21:07:00 -07:00
31998fec05 0.5.23 2016-10-18 13:18:45 -07:00
342aa3ca32 Bump pxt-core to 0.4.63 2016-10-18 13:18:43 -07:00
9b599b6242 0.5.22 2016-10-18 16:56:58 +02:00
e5e63c548f update dal defines 2016-10-18 16:56:42 +02:00
f3eb9a988f update dependencies 2016-10-18 16:56:15 +02:00
e7e2ff7752 gesture updates 2016-10-18 16:40:53 +02:00
f10ac93268 add handling of gestures (we only have 2g, 6g ... no 3g), add mac/idea ignored files 2016-10-18 15:44:49 +02:00
47f46553e0 fix name of board 2016-10-18 15:43:52 +02:00
3158e95cde 0.5.21 2016-10-17 21:39:08 -07:00
854029fe33 updated board name 2016-10-17 21:38:58 -07:00
1b379bddd0 0.5.20 2016-10-17 21:35:07 -07:00
9495da9a53 0.5.19 2016-10-17 21:25:11 -07:00
128b3f2f51 Bump pxt-core to 0.4.62 2016-10-17 21:25:08 -07:00
a331a017b8 merged microbit changes 2016-10-17 13:36:54 -07:00
790b9f557a renaming translation files 2016-10-17 13:33:27 -07:00
0b469f69b6 Fix i18n not working after 277d5a7 (#277)
* Fix i18n not working after 277d5a7

The translation strings file in "core" package should have file names
"core-strings.json" or "core-jsdoc-strings.json".

* Enable ja translation

Rename "core-strings.json" to "core-jsdoc-strings.json".
Add new "core-strings.json" as a copy of the template.
Add two lines for the files in "pxt.json".
2016-10-17 11:13:38 -07:00
5cce86ec7e 0.5.18 2016-10-17 10:54:19 -07:00
65e01dc0df Bump pxt-core to 0.4.59 2016-10-17 10:54:17 -07:00
1a3c31c9f3 Deploy no longer throws when no drives found (#269)
pxt deploy no longer throws when no drives found
2016-10-17 07:39:29 -07:00
7aeb216462 0.5.17 2016-10-16 20:26:19 -07:00
543659b0e8 specifying pin positions 2016-10-16 20:25:55 -07:00
a2b5ff68af 0.5.16 2016-10-16 20:09:30 -07:00
b968d3b1de fixing simulator in IE11 2016-10-16 20:09:13 -07:00
4dbebe3e15 fixing logo in IE11 2016-10-16 09:28:30 -07:00
3b95fede48 optimizing logo 2016-10-16 09:19:40 -07:00
5d4bd77bf4 0.4.49 2016-10-14 22:57:42 -07:00
c83d7e9f07 Bump pxt-core to 0.4.58 2016-10-14 22:57:35 -07:00
971faed80a 0.5.15 2016-10-14 21:56:38 -07:00
02a58caf7a Bump pxt-core to 0.4.58 2016-10-14 21:56:37 -07:00
912e2e6159 enabling inverted menu 2016-10-14 11:32:00 -07:00
efee05c7f5 0.4.48 2016-10-14 11:30:47 -07:00
cc9ab86181 Bump pxt-core to 0.4.57 2016-10-14 11:30:41 -07:00
e834ae0656 0.5.14 2016-10-14 08:04:04 -07:00
175923fcb9 updated logos 2016-10-14 08:00:34 -07:00
42ebdde3df 0.5.13 2016-10-14 07:48:36 -07:00
20c63359af hiding microsoft logo 2016-10-14 07:48:23 -07:00
841f3dc7d6 0.5.12 2016-10-14 07:35:12 -07:00
f7377f6a21 Bump pxt-core to 0.4.57 2016-10-14 07:35:09 -07:00
1104ab5b33 updated logos 2016-10-14 07:21:50 -07:00
e2fe660012 towards pin placement 2016-10-14 06:46:56 -07:00
7d4b800637 identifying and naming pins 2016-10-13 23:53:24 -07:00
ef8d7185ee adding lessons to create circuit using aluminium foil 2016-10-13 12:52:47 -07:00
b0392da8b1 Fix indentation of showLeds in a couple of projects. 2016-10-13 11:32:25 -07:00
c817f9e3ff re-enabling sharing after bug in share-editor has been fixed. 2016-10-13 10:55:52 -07:00
746728759d setting default locale to German 2016-10-13 10:21:56 -07:00
3d3b9e2718 Bump pxt-core to 0.4.56 2016-10-13 10:06:10 -07:00
0459cd693d 0.5.11 2016-10-13 16:58:33 +02:00
9c43714126 fix dependency 2016-10-13 16:58:14 +02:00
9bf7459628 0.5.10 2016-10-13 16:30:38 +02:00
b52432e103 update dependency 2016-10-13 16:26:30 +02:00
3ac0a060dd added pin mapping 2016-10-13 11:16:10 +02:00
85ebbb28e3 0.5.9 2016-10-12 23:52:47 -07:00
f69db3faf7 Bump pxt-core to 0.4.55 2016-10-12 23:52:45 -07:00
5f78f98f94 0.4.47 2016-10-12 23:52:11 -07:00
395b6184b9 Bump pxt-core to 0.4.55 2016-10-12 23:52:09 -07:00
4fc514e643 updated screen rendering 2016-10-12 23:40:33 -07:00
7c2512e56b fixing thermometer 2016-10-12 23:30:19 -07:00
d9eebf4a9f support for light level / thermometer simulation 2016-10-12 23:14:38 -07:00
8af383ec56 updated svg layout 2016-10-12 22:44:05 -07:00
573d7aff40 add svg with pins and connectors id-ed 2016-10-12 23:07:55 +02:00
f73274803c 0.5.8 2016-10-12 18:57:05 +02:00
63556ef14a update dependency 2016-10-12 18:56:51 +02:00
9607183587 0.5.7 2016-10-12 18:02:23 +02:00
4cca961e52 latest version with RGB led support 2016-10-12 18:02:16 +02:00
c2a1668d55 Merge remote-tracking branch 'origin/master' 2016-10-12 17:54:39 +02:00
7102eddc0b add color handling for LED 2016-10-12 17:54:25 +02:00
b34884fe00 updated readme 2016-10-12 08:13:15 -07:00
e768a4dc97 updated links 2016-10-12 08:11:05 -07:00
8b1b1bb869 0.5.6 2016-10-12 04:50:08 -07:00
57deb1749f Bump pxt-core to 0.4.54 2016-10-12 04:50:06 -07:00
3274964a11 0.4.46 2016-10-12 04:49:42 -07:00
f5e8b35df4 Bump pxt-core to 0.4.54 2016-10-12 04:49:40 -07:00
fb82b94f69 0.5.5 2016-10-12 04:03:19 -07:00
d321170da9 Bump pxt-core to 0.4.53 2016-10-12 04:03:17 -07:00
996073728c 0.4.45 2016-10-12 04:02:55 -07:00
1e964ba1ea Bump pxt-core to 0.4.53 2016-10-12 04:02:53 -07:00
dff4f3adb3 basic motor block support 2016-10-11 22:58:53 -07:00
5d8a1b69f6 0.5.4 2016-10-11 19:42:10 -07:00
0b0c2c9466 merged latest pxt 2016-10-11 19:41:59 -07:00
895a099ebf 0.4.44 2016-10-11 19:36:36 -07:00
f7ed06108d Inputorg (#275)
* use typescript from workspace

* fixed tracking in localhost

* updated ordering of input/radio
2016-10-11 19:36:00 -07:00
0ffccdca85 Bump pxt-core to 0.4.52 2016-10-11 17:51:09 -07:00
9f5ebdfb78 Adding advanced attribute to blocks and categories (#273) 2016-10-11 13:48:25 -07:00
9319f10430 0.5.3 2016-10-11 11:43:38 -07:00
c4787e1028 support for rgb led in simulator 2016-10-11 11:41:51 -07:00
cb280af783 fix json in libs/hello 2016-10-11 10:13:30 -07:00
6e64e80c05 Revert "re-enabling sharing after bug has been fixed"
This reverts commit dde16fec14.
2016-10-11 09:37:53 -07:00
4201cb3070 0.5.2 2016-10-11 09:34:26 -07:00
dde16fec14 re-enabling sharing after bug has been fixed 2016-10-11 09:29:44 -07:00
ec7bade8f4 missed file in previous move 2016-10-11 09:21:24 -07:00
d738d8bbf5 0.5.1 2016-10-11 09:14:47 -07:00
a8b1e0bc04 bumping version number 2016-10-11 09:14:32 -07:00
114b7958bc 0.4.32 2016-10-11 09:13:05 -07:00
f45ae5950c 0.4.31 2016-10-11 09:09:25 -07:00
4cdfaf06c0 0.4.30 2016-10-11 09:08:41 -07:00
d48404eb37 integrated pxt-microbit 2016-10-11 09:08:31 -07:00
f4ac599ec2 Bump pxt-core to 0.4.51 2016-10-11 09:05:10 -07:00
a783cdda92 0.4.29 2016-10-11 13:33:35 +02:00
5900c8c9f5 update dependency 2016-10-11 13:32:42 +02:00
e1e8eab93f 0.4.43 2016-10-10 22:10:45 -07:00
dface9083f Bump pxt-core to 0.4.51 2016-10-10 22:10:43 -07:00
31d4afc897 0.4.42 2016-10-10 17:45:43 -07:00
8427e89eb6 updating to pxt 0.4.50 2016-10-10 16:31:47 -07:00
277d5a721c rename "microbit" package to "core" #414 (#270)
* rename "microbit" package to "core" #414

* shouldn't edit the package id.

* updating package.json

* updated the wrong version

* missed updating pxt.json of tests
2016-10-10 16:21:50 -07:00
3911c6522d integrate pxt-microbit changes 2016-10-10 14:43:33 -07:00
00cdb6f9f5 0.4.28 2016-10-10 13:35:54 -07:00
df14445320 updated travis file 2016-10-10 13:34:24 -07:00
553b692a9a 0.4.27 2016-10-10 13:19:17 -07:00
7f2fd0dd09 positioning systemled 2016-10-10 13:16:39 -07:00
ae6917c7b3 0.4.26 2016-10-10 13:03:20 -07:00
5c1d9a342b updated to core v0.5.4 2016-10-10 13:03:08 -07:00
d41724d239 0.4.25 2016-10-10 12:58:42 -07:00
d6a006d18f Bump pxt-core to 0.4.48 2016-10-10 11:25:24 -07:00
cace68acf4 updated hello sample 2016-10-10 11:20:25 -07:00
80131f2928 updated tilt tempo video 2016-10-10 11:04:00 -07:00
51bd8d57aa updated raspbian docs 2016-10-09 21:50:13 -07:00
68ef7c2fc2 fix initialization of Accelerometer (delayed in uBit.init()), enable DAL debugging 2016-10-08 15:15:01 +02:00
4c502f0825 bump pxt-calliope-core dependency 2016-10-08 12:23:29 +02:00
acd974b964 0.4.41 2016-10-07 18:20:56 -07:00
04e0529610 disabling embed 2016-10-07 18:20:42 -07:00
ee3f2e6470 0.4.40 2016-10-07 14:46:24 -07:00
29a4f3cf69 Bump pxt-core to 0.4.48 2016-10-07 14:46:22 -07:00
a2f1cef9ae Merge branch 'master' of github.com:Microsoft/pxt-calliope 2016-10-07 11:39:31 -07:00
e857a94e04 0.4.24 2016-10-07 18:48:34 +02:00
5649495a28 0.4.39 2016-10-07 09:22:29 -07:00
a8a9d7dcf0 Bump pxt-core to 0.4.47 2016-10-07 09:22:27 -07:00
09d7ebaf78 storing target id, version if available 2016-10-07 09:19:14 -07:00
5c6b4c454b 0.4.38 2016-10-07 02:53:34 -07:00
7e1408fc12 Bump pxt-core to 0.4.46 2016-10-07 02:53:32 -07:00
09dc67717c added nickname / github search flag 2016-10-07 02:53:18 -07:00
20dcd5ce34 0.4.37 2016-10-05 17:17:12 -07:00
e092961b5b Bump pxt-core to 0.4.45 2016-10-05 17:17:11 -07:00
28044af979 merge 2016-10-05 17:16:58 -07:00
a9ba0a8f90 adding sharing flags 2016-10-05 17:14:49 -07:00
871694f99f 0.4.36 2016-10-05 15:17:45 -07:00
8f6c81cd53 Bump pxt-core to 0.4.44 2016-10-05 15:17:44 -07:00
c819b815c4 adding sharing flag to pxtarget.json 2016-10-05 15:17:16 -07:00
a714970344 0.4.35 2016-10-04 08:42:57 -07:00
77df714a08 Bump pxt-core to 0.4.42 2016-10-04 08:42:57 -07:00
693a6ba8a9 Remove 3 converter tests with overflowing numbers 2016-10-04 08:20:30 -07:00
5a8122bc8a 0.4.34 2016-10-03 22:35:53 -07:00
c382fc5050 Bump pxt-core to 0.4.41 2016-10-03 22:35:51 -07:00
d69a82d167 updated telegraph project 2016-10-03 22:32:27 -07:00
a30ca46fef merging changes 2016-10-03 22:23:01 -07:00
a56226c08d updated hack-your-headphone lesson 2016-10-03 22:21:36 -07:00
87d34ba030 restructed banana lesson 2016-10-03 19:07:54 -07:00
091917b765 removed linking between projects 2016-10-03 18:55:09 -07:00
42a93a1682 updated accent color 2016-10-03 18:54:07 -07:00
aea09c1830 Minor fixes to guitar demo 2016-10-03 16:37:46 -07:00
5e9eec61c5 Reject promise when deploy to board fails (#267)
* Reject promise when deploy to board fails

* Change var to let
2016-10-03 15:26:41 -07:00
a34f765681 adding guitar to project list 2016-10-03 15:18:20 -07:00
2ae78fe6b8 Updated guitar lessons (#268)
* initial notes

* updated code samples

* splitting the page and preparing layout

* missing gamepad api

* added basic guitar activty md files

added initial draft of guitar lesson - in progress

* word smithing and adding detail for concepts listed

* word smithing and adding detail for concepts listed

* typo in file name

* missing macro

* replaced guitar.png with image from Julia Carlson

* adding a few pictures

* adding cards macros

* few tweaks

* image for accellerometer lesson xyz axis

* fixed the numbering buttons page
-fixed the numbering to restart for each section and asdded spaces after so they don't wrap

* adding a few video links

* pin-press - added circuit info

* more vids

* fixing latest commit

* edits to light sensor and pin-press

* updated descriptions, linking lesson

* pin-press and display-buttons updates
-added dode samples to pin press

* updated making video

* light-sensor updated numbering

* Clean up
Clean up of headings to template style, other fixes

* putting display in template
use h2 with "Step 1:" and image before text

* removed numbered lists for display & light
these topics are code complete

* more consistent formating
Acceleromenter, buttons, light sensosr

* Acceleration Lesson, added art
Lesson steps for Acceleration, art for degree F to C for Map anology+clean up of light sensor topic

* Pin Press code complete
some other basic fomats and edits

* Removed dashes in lesson names
renamed and fixed references to files with "-" in names

* rest of fles w/ dash in name changes

* fixed links to guitar activities

* updated acceleraomter section

* transparency 4 art, image text
added transarency and renamed art, added descriptive text for video and still images

* renamed art

* fixing the merge

* fixing hint

* moved step 2 outside ~hint block

* fixing snippets

* remove guitar from project list

* Duration/Materials consistent  format
moved out of ~avatar block
2016-10-03 14:59:58 -07:00
e983c76e2f Remove unneeded tests 2016-10-03 11:15:49 -07:00
ced4565d5c 0.4.23 2016-10-01 15:52:41 -07:00
2475058b94 0.4.22 2016-10-01 15:45:43 -07:00
c6ee0db81c Bump pxt-core to 0.4.39 2016-10-01 15:45:41 -07:00
1b96e6332a 0.4.21 2016-10-01 21:02:36 +02:00
1ceec1d3b4 0.4.20 2016-10-01 20:59:44 +02:00
2e9ddb48df 0.4.19 2016-10-01 20:58:45 +02:00
33207f33e5 0.4.33 2016-09-30 22:08:18 -07:00
a487e102ef Bump pxt-core to 0.4.39 2016-09-30 22:08:16 -07:00
a6ffa99ceb 0.4.32 2016-09-30 21:51:56 -07:00
d2aa02c259 Bump pxt-core to 0.4.37 2016-09-30 21:51:54 -07:00
563d76b90a 0.4.31 2016-09-30 10:56:30 -07:00
b433585403 disable persistence of cookies 2016-09-30 10:56:11 -07:00
576f37171a 0.4.30 2016-09-30 08:29:54 -07:00
0bd92a433d Bump pxt-core to 0.4.36 2016-09-30 08:29:52 -07:00
2d5f3421ba updated docs page tracking 2016-09-30 08:29:44 -07:00
7956c6e6a1 disable persistence when initializig mix panel 2016-09-30 08:14:13 -07:00
1f7a56a451 0.4.29 2016-09-29 22:46:54 -07:00
0ea4583b20 fix typo in tracking 2016-09-29 22:45:55 -07:00
4bccb435f7 0.4.28 2016-09-29 22:35:06 -07:00
749c2111d2 disaable user-voice, disable cookies in mixpanel 2016-09-29 22:31:10 -07:00
96991447f8 0.4.27 2016-09-29 22:15:19 -07:00
22f36a623b Bump pxt-core to 0.4.35 2016-09-29 22:15:17 -07:00
8a47793f48 reorg lesson 2016-09-29 22:15:04 -07:00
2296220ad7 updated logos 2016-09-29 16:23:37 -07:00
22864bd26a pointing to cloud compile service 2016-09-29 16:13:33 -07:00
574a9e01d5 updating pinmap 2016-09-29 15:25:57 -07:00
00278036a4 fixing pin mapping 2016-09-29 15:20:45 -07:00
5cfedf7343 0.4.26 2016-09-29 08:32:27 -07:00
13383e6232 adding sketeches 2016-09-29 08:32:15 -07:00
165cd0c67e Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-09-29 08:16:14 -07:00
9c8886116e fix for microsoft/pxt#396 2016-09-29 08:15:58 -07:00
fc495b928e Implement getPinAddress in simulator 2016-09-29 10:47:50 +01:00
17644d4947 0.4.25 2016-09-28 22:36:26 -07:00
068ea80a45 Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-09-28 22:36:04 -07:00
7a86bbd6b9 Timingate (#265)
* draft lesson

* basic timing gates lesson
2016-09-28 22:35:53 -07:00
78fffe0e01 typos 2016-09-28 19:24:43 -07:00
7bf1a29c83 0.4.24 2016-09-28 18:08:18 -07:00
446ef4d7b7 Bump pxt-core to 0.4.33 2016-09-28 18:08:14 -07:00
ca3e3a43a5 0.4.23 2016-09-28 17:05:17 -07:00
2225be7af1 added org info 2016-09-28 15:25:58 -07:00
1ce863df96 0.4.22 2016-09-28 11:55:00 -07:00
68ae9864a9 Bump pxt-core to 0.4.32 2016-09-28 11:54:57 -07:00
8cd670b22a 0.4.21 2016-09-28 00:29:43 -07:00
a36038a048 Bump pxt-core to 0.4.30 2016-09-28 00:29:39 -07:00
9d4b31fe4d updated share docs 2016-09-28 00:29:27 -07:00
3ea6d1e6bb 0.4.20 2016-09-27 18:11:07 -07:00
1698c4a012 Bump pxt-core to 0.4.27 2016-09-27 18:11:06 -07:00
4b583e221b limited support for RGB led 2016-09-27 13:35:48 -07:00
c88645d0cd support for AB / Shake buttons 2016-09-27 11:00:21 -07:00
14e8eabd25 updated simulator ratio, domain names 2016-09-27 09:35:52 -07:00
5fab789763 merging microbit 2016-09-26 22:00:04 -07:00
2c39e249f9 New guitar project (#264) 2016-09-26 21:55:39 -07:00
c486a9db94 0.4.19 2016-09-26 16:31:02 -07:00
816438fa79 Bump pxt-core to 0.4.26 2016-09-26 16:30:58 -07:00
33eca3c507 tweaked colors 2016-09-26 15:10:37 -07:00
9ccfcf19d9 initial round of visual updates 2016-09-26 15:05:06 -07:00
5edd06c9b9 migrating instruction generation logic to pxt 2016-09-26 13:26:43 -07:00
a114dc32e7 Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-09-26 10:00:13 -07:00
019bc34d90 Fixing hover text /help window for blocks are not correct 2016-09-26 09:59:52 -07:00
0676d780ab Fixing beat fraction typo (#263) 2016-09-23 22:27:57 -07:00
96e23d99b2 Merge pull request #261 from Microsoft/note_fix
Add annotation to Note.C in music enum
2016-09-23 12:56:41 -07:00
15b1f95394 Add annotation to Note.C in music enum 2016-09-22 14:36:37 -07:00
552b0d8165 0.4.18 2016-09-22 03:56:03 -07:00
faed492a87 Embed docs (#259)
* Generic instructions for embedding

* Wordpress instructions, update Markdown instructions

* Blogger instructions

* Squarespace instructions

* Google sites info

* Sway restrictions

* Correct order
2016-09-22 03:50:59 -07:00
0ce1738653 Remove comment re Safari in private mode 2016-09-22 09:27:46 +01:00
f5cabe6e94 0.4.17 2016-09-21 22:30:10 -07:00
f2e7a640f1 Bump pxt-core to 0.4.25 2016-09-21 22:30:08 -07:00
7fb057af66 0.4.16 2016-09-21 22:14:40 -07:00
c0b9329401 Bump pxt-core to 0.4.24 2016-09-21 22:14:33 -07:00
c04ddbb459 Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-09-21 16:34:06 -07:00
4aac4ef92d Fixing hero lesson 2016-09-21 16:31:03 -07:00
979b2b892a avoid name collision (embed.md => share.md) 2016-09-21 15:01:43 -07:00
4c3f9910f7 0.4.15 2016-09-21 10:55:54 -07:00
9aef584966 Bump pxt-core to 0.4.21 2016-09-21 10:55:52 -07:00
e62d15ba85 Embed docs (#257)
* embed docs

* adding embed docs
2016-09-21 10:15:59 -07:00
adf97d9b5c Add information about Safari being unsupported in private browsing mode 2016-09-21 11:23:43 +01:00
2bb6c6ae27 0.4.14 2016-09-20 22:56:14 -07:00
0919eff0c5 Bump pxt-core to 0.4.18 2016-09-20 22:56:12 -07:00
e31279938b 0.4.13 2016-09-20 22:13:15 -07:00
2655843b74 Bump pxt-core to 0.4.17 2016-09-20 22:13:08 -07:00
527d323ea7 New electron client (#256) 2016-09-20 22:02:18 -07:00
5d40a48477 Merge pull request #255 from Microsoft/browser-versions
More detailed information about which browser versions are supported
2016-09-20 11:54:59 +01:00
850fb54f52 missing shims for devices namespace 2016-09-19 09:49:58 -07:00
6bb35c1a72 More detailed information about which browser versions are supported 2016-09-19 09:31:03 +01:00
6569231ba6 0.4.12 2016-09-16 00:05:53 -07:00
a3a1c8a480 Bump pxt-core to 0.4.15 2016-09-16 00:05:51 -07:00
c90dfaa6e7 added headphone part 2016-09-15 23:50:52 -07:00
02cd0e1da3 remove "receivednumberat" from blocks 2016-09-15 23:49:50 -07:00
0f9dde0c4e convert event source/value into TD_ID shims 2016-09-15 23:49:14 -07:00
1e0cd48316 updated docs 2016-09-15 11:04:45 -07:00
d959282c68 0.4.11 2016-09-15 10:50:25 -07:00
d513ad7713 Bump pxt-core to 0.4.13 2016-09-15 10:50:23 -07:00
b7da28285e adding stubs for bluetooth functions 2016-09-15 09:40:58 -07:00
dbaf406703 splitted usb transfer instructions 2016-09-15 08:35:01 -07:00
2cb467f22b 0.4.10 2016-09-15 07:26:32 -07:00
9585e2276d Bump pxt-core to 0.4.12 2016-09-15 07:26:29 -07:00
a591d9f072 Release build of Mac client 2016-09-15 09:25:33 +01:00
471a30ca3d Minimise memory usage in Mac app directory watcher 2016-09-15 09:24:09 +01:00
205b94afe8 Launch editor menu item in Mac app 2016-09-15 09:23:48 +01:00
18caf554e9 Use micro:bit image for Mac app icon
I’m continuing to use the same menu bar image, as usually these are black and white on OS X, compared to coloured images being common on the Windows task bar.
2016-09-15 09:17:54 +01:00
67cdf16fe4 Remove redundant values from MainMenu.xib
A small section of this file is still required to build and run the app (it contains metadata that declares that AppDelegate.m is the main implementation, for example).
2016-09-15 08:51:49 +01:00
bdbe8371dd 0.4.9 2016-09-14 22:50:29 -07:00
21a36eb9ee fixing broken image paths 2016-09-14 22:43:59 -07:00
376b20b035 0.4.8 2016-09-14 22:28:23 -07:00
7ce41b52aa fixing path in docs 2016-09-14 22:28:05 -07:00
46f7831e7c 0.4.7 2016-09-14 22:21:00 -07:00
dda29a5cb6 Bump pxt-core to 0.4.11 2016-09-14 22:20:58 -07:00
6e4f4595a2 updated usb images 2016-09-14 22:18:01 -07:00
cdbe1e513b 0.4.6 2016-09-14 20:38:49 -07:00
ae15c9a656 Bump pxt-core to 0.4.9 2016-09-14 20:38:47 -07:00
d993ff3a9d 0.4.5 2016-09-14 11:33:54 -07:00
13785a2438 OS X uploader (#252)
* Source for OS X uploader

* Readme for OS X uploader

* Export image

* .gitignore for Xcode project

* Remove redundant data

* Update readme instructions

* List formatting

* Remove personal copyright notice added by Xcode

* Added release build and updated readme

* point to doc cdn
2016-09-14 11:33:11 -07:00
4dfb77fcd7 0.4.4 2016-09-14 08:16:32 -07:00
70deffb665 Bump pxt-core to 0.4.8 2016-09-14 08:16:29 -07:00
41a148de28 Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-09-14 08:14:41 -07:00
886e071d7f updated about to link to docs 2016-09-14 08:14:04 -07:00
8a58d664c3 adding clear image in stopanimation 2016-09-14 07:54:35 -07:00
71d1155f21 Add file forgotten in 50473255a8 2016-09-14 12:31:52 +03:00
167c1d8fce loading board definition from pxtarget.json 2016-09-13 15:32:12 -07:00
e59ae37954 moving neopixel state to pxt 2016-09-13 13:09:02 -07:00
72a621ec8b mvoing edge connector to pxt 2016-09-13 12:48:07 -07:00
d6ff930333 fix capitalized file names 2016-09-13 10:36:25 -07:00
54a7ac81ea Recommended browser documentation (#251)
* Documentation page for unsupported browsers

* Update unsupported documentation with mac info

* Blur irrelevant information in version screenshots

* Rename to Peli's suggested path

* Browser recommendation for each platform
2016-09-13 10:33:06 -07:00
e5d985dbf1 moving boardhost to pxt 2016-09-13 09:59:34 -07:00
9db91d89d6 refactor part global lists 2016-09-13 09:44:58 -07:00
1fa9bf12d5 refactoring dalboard 2016-09-12 21:29:55 -07:00
61bab257eb 0.4.3 2016-09-12 11:45:22 -07:00
2e90b351da updated other download picture 2016-09-12 11:33:16 -07:00
801bd6c7a0 udpated download pictures 2016-09-12 11:30:12 -07:00
777ba40899 0.4.2 2016-09-12 11:19:41 -07:00
0d11c16ecf Bump pxt-core to 0.4.3 2016-09-12 11:19:39 -07:00
9c1628b977 Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-09-12 11:11:12 -07:00
953b362b34 Download instructions (#250)
* Images of micro:bit attached t ostuff

* Cropped and enhanced USB images

* Define paths for USB images

* Added new matching criteria for images

* Help URL

* Add paths for all images

* Cropped images so they look better on dialog

* Add link to uploader
2016-09-12 11:10:30 -07:00
8b40850a94 tweaks to neopixel rendering 2016-09-11 21:55:54 -07:00
fc3a02cc41 0.4.1 2016-09-11 18:07:11 +01:00
80f2ff6757 Bump to 0.4 to match pxt-core 2016-09-11 18:07:05 +01:00
6f790d167c 0.3.89 2016-09-11 18:06:20 +01:00
ac7502074a Bump pxt-core to 0.4.2 2016-09-11 18:06:20 +01:00
50473255a8 Utylize the new target.css file 2016-09-11 17:51:41 +01:00
910772d54e refacotring various simulator features into pxt 2016-09-09 22:56:26 -07:00
33f12f9ecc 0.3.88 2016-09-09 16:41:31 -07:00
01fa4ef53a Bump pxt-core to 0.3.102 2016-09-09 16:41:14 -07:00
3858b0a0a0 moving wiring to pxt 2016-09-09 15:01:29 -07:00
da30afb121 Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-09-09 13:43:45 -07:00
086bcf372f remove dependencies on dal.d.ts 2016-09-09 13:43:41 -07:00
236e7337e2 0.3.87 2016-09-09 20:49:21 +01:00
4cf223271f Bump pxt-core to 0.3.100 2016-09-09 20:49:21 +01:00
10180f4729 Merge branch 'master' of github.com:Microsoft/pxt-microbit 2016-09-09 20:49:19 +01:00
618dd33221 No longer used 2016-09-09 20:33:11 +01:00
7356e5e52e New index.html expansion 2016-09-09 20:26:18 +01:00
a59d148eb5 0.3.86 2016-09-09 12:23:25 -07:00
34ce687bbd Bump pxt-core to 0.3.98 2016-09-09 12:23:24 -07:00
5e241ed566 Use new doc templates 2016-09-09 20:19:52 +01:00
dcb2b21e66 removing dal dependency 2016-09-09 11:36:36 -07:00
95669e174a Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-09-09 09:59:21 -07:00
aca7d6113d enable streams in pxtarget 2016-09-09 09:59:07 -07:00
ef4b06a087 Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-09-09 15:19:58 +01:00
afa69c23c4 0.3.85 2016-09-09 11:35:45 +01:00
8229e71d0a Bump pxt-core to 0.3.97 2016-09-09 11:35:45 +01:00
93770e5821 Merge branch 'master' of github.com:Microsoft/pxt-microbit 2016-09-09 10:17:35 +01:00
cb8e28beb0 Bump pxt-microbit-core to 0.5.0 2016-09-09 10:17:28 +01:00
8c7e6055ff enabling parts in target 2016-09-09 01:39:52 -07:00
8450db55ac 0.3.84 2016-09-09 01:25:28 -07:00
c63e2c85f1 new part definitions (#247)
* working on new part definitions

* draft of new part definitions

* updates comments

* starting new allocator

* starting from the old allocator

* alloc internals renaming

* alloc minor renaming

* alloc internal renaming

* progress on new parts definition

* progress on new part defs allocator

* refactors BBLoc; progress on new allocator

* more progress on new allocator

* finishing new allocator

* deleting old allocator

* moves new allocator and part definitions

* porting to new part definitions

* refactors instructions for new definitions

* debugging new allocator

* fixes ground and power wire colros

* fixing new part definition bugs

* fixes wire end offsets; fixes NeoPixel placement

* fixes colorGroup issue

* fixes led matrix wiring

* naming tweaks

* fixes instructions regressions

* typo
2016-09-09 01:23:39 -07:00
d8fc11a688 0.3.83 2016-09-09 01:20:45 -07:00
847a29848d Bump pxt-core to 0.3.96 2016-09-09 01:20:43 -07:00
39f4372ee5 0.3.82 2016-09-08 23:39:26 -07:00
a8bbbea8ed Bump pxt-core to 0.3.95 2016-09-08 23:39:24 -07:00
91a8d05e45 updated loc strings 2016-09-08 23:11:58 -07:00
3ecedd3a32 0.3.81 2016-09-08 01:02:46 -07:00
b6390d77dd Bump pxt-core to 0.3.94 2016-09-08 01:02:40 -07:00
e8f9e0f023 lighter rendering of breadboard in grayed 2016-09-08 00:54:19 -07:00
2bacb58fdd simpler instructions 2016-09-08 00:46:43 -07:00
af8babfea2 Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-09-08 00:03:33 -07:00
1ee6274100 added raspberry-pi instructions 2016-09-08 00:00:07 -07:00
7448db5b98 makes instruction panels inline-block 2016-09-07 15:00:42 -07:00
983645403b 0.3.80 2016-09-07 11:49:41 -07:00
7a9f382bee Merge pull request #240 from Microsoft/neopixel-improvement
improves neopixel simulator
2016-09-07 11:22:40 -07:00
e59fd8469b improves neopixel simulator 2016-09-07 10:58:44 -07:00
008c886de9 0.3.79 2016-09-07 16:51:08 +01:00
c87fa30738 Bump pxt-core to 0.3.93 2016-09-07 16:51:08 +01:00
dd9d1299fa Merge branch 'master' of github.com:Microsoft/pxt-microbit 2016-09-07 16:27:42 +01:00
6a7d1bd95c Support for object literals
bump pxt-microbit-core to 0.4.4
see https://github.com/Microsoft/pxt/issues/287
2016-09-07 16:27:28 +01:00
dfe270d259 Correct filename of data.csv in radio challenge 2016-09-07 11:32:41 +01:00
6deb0683b6 Add GitHub URL property 2016-09-07 10:33:36 +01:00
0a746f5bbe 0.3.78 2016-09-06 20:41:04 -07:00
066408c317 Bump pxt-core to 0.3.92 2016-09-06 20:41:02 -07:00
90f7b229d1 0.3.77 2016-09-06 13:41:41 -07:00
c54e0b0e9d Bump pxt-core to 0.3.90 2016-09-06 13:41:35 -07:00
ea088ac828 renaming docs image files 2016-09-06 13:31:47 -07:00
29cf4d3e53 uses croc clips in instructions only for micro:bit 2016-09-06 10:52:22 -07:00
6d637eefd7 scaling, cropping,blurring 2016-09-06 10:06:09 -07:00
6310e96ac2 Merge pull request #239 from Microsoft/usb-docs-update
.hex file download and USB transfer docs update
2016-09-06 09:10:06 -07:00
dbb1e31822 Remove DS_STORE 2016-09-06 10:01:12 +01:00
5376bc2dce Rename images, remove redundant images 2016-09-06 09:57:45 +01:00
57bd293df8 Move arrow position on doc image 2016-09-06 09:52:17 +01:00
e570d46755 Rewrite instructions on downloading files to make them more clear 2016-09-06 09:49:08 +01:00
d37f284fce Added arrows to images and updated instructions 2016-09-06 09:28:20 +01:00
b716226889 Images for Windows 2016-09-06 09:05:33 +01:00
1bd19cc1a0 support list micro:bit on linux 2016-09-06 00:12:57 -07:00
ac8c9c5e85 Updating editor screenshots in js/cal, fixes #230 2016-09-05 09:04:03 -07:00
057260c483 Update OS X Firefox screenshots and instructions 2016-09-05 16:46:56 +01:00
568ae32f81 Update screenshot and instructions for OS X Chrome 2016-09-05 16:32:41 +01:00
ae605ff829 Update OS X file transfer screenshot 2016-09-05 16:22:06 +01:00
f25ddb1085 OS X screenshot 2016-09-05 15:50:27 +01:00
f175f973f0 0.3.76 2016-09-05 14:26:24 +01:00
c7e5fa490e Bump pxt-core to 0.3.87 2016-09-05 14:26:24 +01:00
61a29f7c67 Always diplay sad face on errors; use nullCheck() function; see https://github.com/Microsoft/pxt/issues/302 2016-09-05 14:26:07 +01:00
50293fc654 don't repace spaces 2016-09-02 21:38:22 -07:00
a9ecadaf09 Merge pull request #238 from Microsoft/power-usage
Direct power wires for single usages
2016-09-02 21:13:15 -07:00
6e56107eb5 Merge branch 'master' into power-usage 2016-09-02 16:12:48 -07:00
1f077beb65 directly wires power if there is single usage 2016-09-02 16:11:58 -07:00
8fff762156 removed uwp info 2016-09-02 16:08:49 -07:00
cebded2526 Merge pull request #237 from Microsoft/power-usage
finer grain power wires based on usage
2016-09-02 16:07:02 -07:00
13f53d730a fixes instruction steps for finer power usage 2016-09-02 15:43:26 -07:00
8adcab1cab finer grain power wires based on usage 2016-09-02 15:24:16 -07:00
298 changed files with 9316 additions and 6317 deletions

4
.gitignore vendored
View File

@ -24,3 +24,7 @@ clients/electron/projects
*.db
*.suo
*.log
.DS_Store
.idea
*.iml

View File

@ -3,17 +3,12 @@ node_js:
- "5.7.0"
script:
- "node node_modules/pxt-core/built/pxt.js travis"
- "(cd libs/lang-test0; node ../../node_modules/pxt-core/built/pxt.js run)"
- "(cd libs/lang-test1; node ../../node_modules/pxt-core/built/pxt.js run)"
- "(cd libs/lang-test0; node ../../node_modules/pxt-core/built/pxt.js test)"
- "(cd libs/lang-test1; node ../../node_modules/pxt-core/built/pxt.js test)"
- "node node_modules/pxt-core/built/pxt.js testdir tests"
- "node node_modules/pxt-core/built/pxt.js uploaddoc"
- "(cd libs/hello; node ../../node_modules/pxt-core/built/pxt.js testconv https://az851932.vo.msecnd.net/files/td-converter-tests-v0.json)"
sudo: false
notifications:
email:
- touchdevelop-build@microsoft.com
- kindscript@microsoft.com
cache:
directories:
- node_modules

View File

@ -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"
}

View File

@ -1,11 +1,11 @@
# micro:bit target for PXT
# Calliope target for PXT
This target allow to program a [BBC micro:bit](https://www.microbit.co.uk/) using
This target allow to program a [Calliope](http://calliope.cc/) using
PXT ([Microsoft Programming Experience Toolkit](https://github.com/Microsoft/pxt)).
* [Try it live](https://codethemicrobit.com)
[![Build Status](https://travis-ci.org/Microsoft/pxt-calliope.svg?branch=master)](https://travis-ci.org/Microsoft/pxt-calliope)
[![Build Status](https://travis-ci.org/Microsoft/pxt-microbit.svg?branch=master)](https://travis-ci.org/Microsoft/pxt-microbit)
![](http://calliope.cc/content/1-ueber-mini/mini_board.png)
## Local server
@ -18,8 +18,8 @@ The following commands are a 1-time setup after synching the repo on your machin
* if not yet installed, install [Node.js 4.4.5 or higher](https://nodejs.org/en/download/)
* [clone this repo](https://help.github.com/articles/cloning-a-repository/) to your computer and go in the project folder
```
git clone https://github.com/microsoft/pxt-microbit
cd pxt-microbit
git clone https://github.com/microsoft/pxt-calliope
cd pxt-calliope
```
* install the PXT command line (add ``sudo`` for Mac/Linux shells).
```
@ -32,14 +32,15 @@ npm install
### Running
Run this command to open a local web server (add ``sudo`` for Mac/Linux shells)
Run this command to open a local web server (add ``sudo`` for Mac/Linux shells).
```
pxt serve
```
If the local server opens in the wrong browser, make sure to copy the URL containing the local token.
Otherwise, the editor will not be able to load the projects.
If you need modify the `.cpp` files, turn on yotta compilation with the ``-yt`` flag (add ``sudo`` for Mac/Linux shells):
If you need modify the `.cpp` files, turn on yotta compilation with the ``-yt`` flag (add ``sudo`` for Mac/Linux shells). On Windows, you must be running
from the ``Run Yotta`` command prompt.
```
pxt serve -yt
```
@ -53,16 +54,6 @@ pxt update
More instructions at https://github.com/Microsoft/pxt#running-a-target-from-localhost
## Universal Windows App
The Windows 10 app is a [Universal Windows Hosted Web App](https://microsoftedge.github.io/WebAppsDocs/en-US/win10/CreateHWA.htm)
that wraps ``codethemicrobit.com`` and provides additional features.
### Building
* Install Visual Studio 2015 Update 2 or higher. Make sure the Windows 10 templates are installed.
* open the ``win10/app.sln`` solution and launch the ``codethemicrobit`` project.
## Testing
The build automatically runs the following:
@ -71,7 +62,6 @@ The build automatically runs the following:
* `pxt run` in `libs/lang-test*` - this will run the test in command line runner;
there is a number of asserts in both of these
* `pxt testdir` in `tests` - this makes sure all the files compile and generates .hex files
* run the TD->TS converter on a number of test scripts from `microbit.co.uk` and make sure the results compile
To test something on the device:

2
clients/electron/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules
projects

View File

@ -0,0 +1,5 @@
# PXT micro:bit Electron app
A very basic wrapper around the web app. To install, copy the contents of this
directory to somewhere outside the main `pxt-microbit` repository. Then run `npm
install && npm start`.

View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>code the micro:bit</title>
</head>
<body>
<webview id="webview" style="position:absolute; left:0; top:0; right:0; bottom:0"/>
<script>
const webview = document.getElementById("webview")
const url = `http://localhost:3232/${window.location.hash}`
webview.src = url
</script>
</body>
</html>

View File

@ -1,67 +1,39 @@
const electron = require('electron')
// Module to control application life.
const app = electron.app
// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow
// pxt toolchain
const {app, BrowserWindow, Menu} = require('electron')
const pxt = require('pxt-core')
const path = require('path')
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow
let win
function createWindow() {
console.log('starting app...')
// Create the browser window.
mainWindow = new BrowserWindow({
width: 800, height: 600,
webPreferences: {
nodeIntegration: false,
}
const cliPath = path.join(process.cwd(), "node_modules/pxt-microbit")
function startServerAndCreateWindow() {
pxt.mainCli(cliPath, ["serve", "-no-browser"])
createWindow()
}
function createWindow () {
win = new BrowserWindow({
width: 800,
height: 600,
title: "code the micro:bit"
})
ts.pxt.Util.debug = true;
pxt.mainCli("C:/gh/pxt-microbit/clients/electron/node_modules/pxt-microbit", ["serve", "-just"]);
// no menu
mainWindow.setMenu(null);
// and load the index.html of the app.
mainWindow.loadURL(`http://localhost:3232/#local_token=08ba9b8f-6ccb-4202-296d-28fac7a553d9`)
// Open the DevTools.
mainWindow.webContents.openDevTools()
// Emitted when the window is closed.
mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null
Menu.setApplicationMenu(null)
win.loadURL(`file://${__dirname}/index.html#local_token=${pxt.globalConfig.localToken}`)
win.on('closed', () => {
win = null
})
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow)
app.on('ready', startServerAndCreateWindow)
// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
app.on('activate', () => {
if (win === null) {
createWindow()
}
})
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.

View File

@ -1,19 +1,14 @@
{
"name": "codethemicrobit",
"version": "0.1.0",
"description": "A Blocks / JavaScript editor for the micro:bit",
"main": "main.js",
"scripts": {
"start": "electron ."
},
"name" : "code-the-microbit",
"version" : "1.0.0",
"description": "Blocks / Javascript editor",
"author": "Microsoft",
"license": "MIT",
"devDependencies": {
"electron-prebuilt": "^1.2.0"
"main" : "main.js",
"scripts": {
"start": "node_modules/.bin/electron ."
},
"dependencies": {
"typescript": "1.8.7",
"pxt-core": "*",
"pxt-microbit": "*"
"devDependencies": {
"electron": "*",
"pxt-microbit": "*"
}
}
}

137
clients/macuploader/.gitignore vendored Normal file
View File

@ -0,0 +1,137 @@
# Created by https://www.gitignore.io/api/osx,xcode,objective-c,vim
### OSX ###
*.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Xcode ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint
### Objective-C ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
## Other
*.moved-aside
*.xcuserstate
## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build
# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode
iOSInjectionProject/
### Objective-C Patch ###
*.xcscmblueprint
### Vim ###
# swap
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
# session
Session.vim
# temporary
.netrwhist
*~
# auto-generated tag files
tags

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

View File

@ -0,0 +1,307 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
E93040071D895D1F00D931CA /* DirectoryWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = E93040061D895D1F00D931CA /* DirectoryWatcher.m */; };
E930400A1D89620900D931CA /* Uploader.m in Sources */ = {isa = PBXBuildFile; fileRef = E93040091D89620900D931CA /* Uploader.m */; };
E9F4FEE21D8709980071D783 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E9F4FEE11D8709980071D783 /* AppDelegate.m */; };
E9F4FEE51D8709980071D783 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E9F4FEE41D8709980071D783 /* main.m */; };
E9F4FEE71D8709980071D783 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E9F4FEE61D8709980071D783 /* Assets.xcassets */; };
E9F4FEEA1D8709980071D783 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = E9F4FEE81D8709980071D783 /* MainMenu.xib */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
E93040051D895D1F00D931CA /* DirectoryWatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DirectoryWatcher.h; sourceTree = "<group>"; };
E93040061D895D1F00D931CA /* DirectoryWatcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DirectoryWatcher.m; sourceTree = "<group>"; };
E93040081D89620900D931CA /* Uploader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Uploader.h; sourceTree = "<group>"; };
E93040091D89620900D931CA /* Uploader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Uploader.m; sourceTree = "<group>"; };
E9F4FEDD1D8709980071D783 /* Microbit Uploader.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Microbit Uploader.app"; sourceTree = BUILT_PRODUCTS_DIR; };
E9F4FEE01D8709980071D783 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
E9F4FEE11D8709980071D783 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
E9F4FEE41D8709980071D783 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
E9F4FEE61D8709980071D783 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
E9F4FEE91D8709980071D783 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
E9F4FEEB1D8709980071D783 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
E9F4FEDA1D8709980071D783 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
E9F4FED41D8709980071D783 = {
isa = PBXGroup;
children = (
E9F4FEDF1D8709980071D783 /* Microbit Uploader */,
E9F4FEDE1D8709980071D783 /* Products */,
);
sourceTree = "<group>";
};
E9F4FEDE1D8709980071D783 /* Products */ = {
isa = PBXGroup;
children = (
E9F4FEDD1D8709980071D783 /* Microbit Uploader.app */,
);
name = Products;
sourceTree = "<group>";
};
E9F4FEDF1D8709980071D783 /* Microbit Uploader */ = {
isa = PBXGroup;
children = (
E9F4FEE01D8709980071D783 /* AppDelegate.h */,
E9F4FEE11D8709980071D783 /* AppDelegate.m */,
E9F4FEE61D8709980071D783 /* Assets.xcassets */,
E9F4FEE81D8709980071D783 /* MainMenu.xib */,
E9F4FEEB1D8709980071D783 /* Info.plist */,
E9F4FEE31D8709980071D783 /* Supporting Files */,
E93040051D895D1F00D931CA /* DirectoryWatcher.h */,
E93040061D895D1F00D931CA /* DirectoryWatcher.m */,
E93040081D89620900D931CA /* Uploader.h */,
E93040091D89620900D931CA /* Uploader.m */,
);
path = "Microbit Uploader";
sourceTree = "<group>";
};
E9F4FEE31D8709980071D783 /* Supporting Files */ = {
isa = PBXGroup;
children = (
E9F4FEE41D8709980071D783 /* main.m */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
E9F4FEDC1D8709980071D783 /* Microbit Uploader */ = {
isa = PBXNativeTarget;
buildConfigurationList = E9F4FEEE1D8709980071D783 /* Build configuration list for PBXNativeTarget "Microbit Uploader" */;
buildPhases = (
E9F4FED91D8709980071D783 /* Sources */,
E9F4FEDA1D8709980071D783 /* Frameworks */,
E9F4FEDB1D8709980071D783 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = "Microbit Uploader";
productName = "Microbit Uploader";
productReference = E9F4FEDD1D8709980071D783 /* Microbit Uploader.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
E9F4FED51D8709980071D783 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = thomasdenney;
TargetAttributes = {
E9F4FEDC1D8709980071D783 = {
CreatedOnToolsVersion = 7.3.1;
};
};
};
buildConfigurationList = E9F4FED81D8709980071D783 /* Build configuration list for PBXProject "Microbit Uploader" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = E9F4FED41D8709980071D783;
productRefGroup = E9F4FEDE1D8709980071D783 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
E9F4FEDC1D8709980071D783 /* Microbit Uploader */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
E9F4FEDB1D8709980071D783 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
E9F4FEE71D8709980071D783 /* Assets.xcassets in Resources */,
E9F4FEEA1D8709980071D783 /* MainMenu.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
E9F4FED91D8709980071D783 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
E9F4FEE51D8709980071D783 /* main.m in Sources */,
E930400A1D89620900D931CA /* Uploader.m in Sources */,
E9F4FEE21D8709980071D783 /* AppDelegate.m in Sources */,
E93040071D895D1F00D931CA /* DirectoryWatcher.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
E9F4FEE81D8709980071D783 /* MainMenu.xib */ = {
isa = PBXVariantGroup;
children = (
E9F4FEE91D8709980071D783 /* Base */,
);
name = MainMenu.xib;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
E9F4FEEC1D8709980071D783 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
E9F4FEED1D8709980071D783 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
};
name = Release;
};
E9F4FEEF1D8709980071D783 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = "Microbit Uploader/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.thomasdenney.Microbit-Uploader";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
E9F4FEF01D8709980071D783 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = "Microbit Uploader/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.thomasdenney.Microbit-Uploader";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
E9F4FED81D8709980071D783 /* Build configuration list for PBXProject "Microbit Uploader" */ = {
isa = XCConfigurationList;
buildConfigurations = (
E9F4FEEC1D8709980071D783 /* Debug */,
E9F4FEED1D8709980071D783 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
E9F4FEEE1D8709980071D783 /* Build configuration list for PBXNativeTarget "Microbit Uploader" */ = {
isa = XCConfigurationList;
buildConfigurations = (
E9F4FEEF1D8709980071D783 /* Debug */,
E9F4FEF01D8709980071D783 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = E9F4FED51D8709980071D783 /* Project object */;
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:Microbit Uploader.xcodeproj">
</FileRef>
</Workspace>

View File

@ -0,0 +1,6 @@
#import <Cocoa/Cocoa.h>
@interface AppDelegate : NSObject <NSApplicationDelegate>
@end

View File

@ -0,0 +1,130 @@
#import "AppDelegate.h"
#import "DirectoryWatcher.h"
#import "Uploader.h"
@interface AppDelegate ()<DirectoryWatcherDelegate, UploaderDelegate, NSUserNotificationCenterDelegate>
@property DirectoryWatcher * watcher;
@property Uploader * uploader;
@property NSStatusItem * menubarItem;
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
self.watcher = [[DirectoryWatcher alloc] initWithPath:[self downloadsDirectory]];
self.watcher.delegate = self;
[self.watcher startWatching];
self.uploader = [[Uploader alloc] init];
self.uploader.delegate = self;
[NSUserNotificationCenter defaultUserNotificationCenter].delegate = self;
[self createMenuBarIcon];
[self configureVolumeMountNotifications];
[self showActiveMicroBits];
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
// Insert code here to tear down your application
[self.watcher stopWatching];
}
- (void)dealloc {
[[NSWorkspace sharedWorkspace].notificationCenter removeObserver:self];
}
#pragma mark - Directory
- (void)watcher:(DirectoryWatcher *)watcher observedNewFileAtPath:(NSString *)path {
NSString * fullPath = [watcher.path stringByAppendingPathComponent:path];
if ([self.uploader shouldUploadFileAtPath:fullPath]) {
[self.uploader uploadFile:fullPath];
}
}
- (NSString*)downloadsDirectory {
NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory, NSUserDomainMask, YES);
return paths.firstObject;
}
#pragma mark - Uploader delegate
- (void)uploader:(Uploader *)uploader transferredFile:(NSString *)file toMicroBit:(NSString *)microbit {
[self showNotification:@"micro:bit upload" withDescription:[NSString stringWithFormat:@"%@ uploaded to %@", file.lastPathComponent, microbit]];
}
- (void)uploader:(Uploader *)uploader failedToTransferFile:(NSString *)file toMicroBit:(NSString *)microbit {
[self showNotification:@"micro:bit upload failed" withDescription:[NSString stringWithFormat:@"Couldn't transfer %@ to %@", file.lastPathComponent, microbit]];
}
- (void)showNotification:(NSString*)title withDescription:(NSString*)description {
NSUserNotification * notification = [NSUserNotification new];
notification.title = title;
notification.informativeText = description;
notification.soundName = NSUserNotificationDefaultSoundName;
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
}
#pragma mark - NSUserNotificationCenterDelegate
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification {
return YES;
}
#pragma mark - Volume mount/unmount notification
- (void)configureVolumeMountNotifications {
[[NSWorkspace sharedWorkspace].notificationCenter addObserver:self selector:@selector(volumeMountNotification:) name:NSWorkspaceDidRenameVolumeNotification object:nil];
[[NSWorkspace sharedWorkspace].notificationCenter addObserver:self selector:@selector(volumeMountNotification:) name:NSWorkspaceDidMountNotification object:nil];
[[NSWorkspace sharedWorkspace].notificationCenter addObserver:self selector:@selector(volumeMountNotification:) name:NSWorkspaceDidUnmountNotification object:nil];
}
- (void)volumeMountNotification:(NSNotification*)sender {
//Delay upadting the menu to give the chance for the disk to fully mount or unmount
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self showActiveMicroBits];
});
}
#pragma mark - Menu bar app
- (void)createMenuBarIcon {
self.menubarItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength];
self.menubarItem.button.image = [NSImage imageNamed:@"menubar"];
}
- (void)showActiveMicroBits {
NSMenu * menu = [NSMenu new];
NSString * countString;
NSUInteger count = self.uploader.microBitPaths.count;
if (count == 0) {
countString = @"No connect micro:bits";
}
else if (count == 1) {
countString = @"1 connected micro:bit";
}
else {
countString = [NSString stringWithFormat:@"%lu connected micro:bits", count];
}
NSMenuItem * microBitCount = [[NSMenuItem alloc] initWithTitle:countString action:nil keyEquivalent:@""];
microBitCount.enabled = NO;
[menu addItem:microBitCount];
NSMenuItem * websiteItem = [[NSMenuItem alloc] initWithTitle:@"Editor" action:@selector(launchEditor:) keyEquivalent:@"e"];
[menu addItem:websiteItem];
NSMenuItem * quitItem = [[NSMenuItem alloc] initWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
[menu addItem:quitItem];
self.menubarItem.menu = menu;
}
- (void)launchEditor:(id)sender {
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://codethemicrobit.com/"]];
}
@end

View File

@ -0,0 +1,68 @@
{
"images" : [
{
"size" : "16x16",
"idiom" : "mac",
"filename" : "icon_16x16.png",
"scale" : "1x"
},
{
"size" : "16x16",
"idiom" : "mac",
"filename" : "icon_16x16@2x.png",
"scale" : "2x"
},
{
"size" : "32x32",
"idiom" : "mac",
"filename" : "icon_32x32.png",
"scale" : "1x"
},
{
"size" : "32x32",
"idiom" : "mac",
"filename" : "icon_32x32@2x.png",
"scale" : "2x"
},
{
"size" : "128x128",
"idiom" : "mac",
"filename" : "icon_128x128.png",
"scale" : "1x"
},
{
"size" : "128x128",
"idiom" : "mac",
"filename" : "icon_128x128@2x.png",
"scale" : "2x"
},
{
"size" : "256x256",
"idiom" : "mac",
"filename" : "icon_256x256.png",
"scale" : "1x"
},
{
"size" : "256x256",
"idiom" : "mac",
"filename" : "icon_256x256@2x.png",
"scale" : "2x"
},
{
"size" : "512x512",
"idiom" : "mac",
"filename" : "icon_512x512.png",
"scale" : "1x"
},
{
"size" : "512x512",
"idiom" : "mac",
"filename" : "icon_512x512@2x.png",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

View File

@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,15 @@
{
"images" : [
{
"idiom" : "mac",
"filename" : "menubar.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
}
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11201" systemVersion="15G1004" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11201"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
<connections>
<outlet property="delegate" destination="Voe-Tx-rLC" id="GzC-gU-4Uq"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate"/>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
</objects>
</document>

View File

@ -0,0 +1,24 @@
#import <Foundation/Foundation.h>
@class DirectoryWatcher;
@protocol DirectoryWatcherDelegate <NSObject>
- (void)watcher:(DirectoryWatcher*)watcher observedNewFileAtPath:(NSString*)path;
@end
@interface DirectoryWatcher : NSObject
- (instancetype)initWithPath:(NSString*)path;
@property (readonly) NSString * path;
@property id<DirectoryWatcherDelegate> delegate;
- (void)startWatching;
//Automatically called when deallocated
- (void)stopWatching;
@end

View File

@ -0,0 +1,75 @@
#import "DirectoryWatcher.h"
#import <CoreServices/CoreServices.h>
void callback(ConstFSEventStreamRef streamRef, void * info, size_t numEvents, void * eventPaths, const FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[]);
@interface DirectoryWatcher ()
@property NSString * path;
@property NSMutableSet<NSString*>* knownFiles;
@property FSEventStreamRef stream;
- (void)rescanPathWithEvents:(BOOL)sendEvents;
@end
@implementation DirectoryWatcher
- (instancetype)initWithPath:(NSString *)path {
if (!path) {
return nil;
}
self = [super init];
if (self) {
self.path = path;
}
return self;
}
- (void)dealloc {
[self stopWatching];
}
- (void)startWatching {
self.knownFiles = [NSMutableSet new];
[self rescanPathWithEvents:NO];
CFStringRef path = (__bridge CFStringRef)(self.path);
CFArrayRef pathsToWatch = CFArrayCreate(NULL, (const void**)&path, 1, NULL);
CFAbsoluteTime latency = 1;
FSEventStreamContext context = { 0, (__bridge void * _Nullable)(self), NULL, NULL, NULL };
self.stream = FSEventStreamCreate(NULL, &callback, &context, pathsToWatch, kFSEventStreamEventIdSinceNow, latency, kFSEventStreamCreateFlagNone);
FSEventStreamScheduleWithRunLoop(self.stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
FSEventStreamStart(self.stream);
}
- (void)stopWatching {
if (self.stream) {
FSEventStreamStop(self.stream);
FSEventStreamInvalidate(self.stream);
FSEventStreamRelease(self.stream);
self.stream = nil;
}
}
- (void)rescanPathWithEvents:(BOOL)sendEvents {
NSArray<NSString*>* downloadFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:self.path error:nil];
NSMutableSet<NSString*>* fullSet = [NSMutableSet new];
for (NSString * file in downloadFiles) {
[fullSet addObject:file];
if (![self.knownFiles containsObject:file]) {
if (sendEvents) {
[self.delegate watcher:self observedNewFileAtPath:file];
}
}
}
self.knownFiles = fullSet;
}
@end
void callback(ConstFSEventStreamRef streamRef, void * info, size_t numEvents, void * eventPaths, const FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[]) {
DirectoryWatcher * watcher = (__bridge DirectoryWatcher*)info;
[watcher rescanPathWithEvents:YES];
}

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.01</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>LSUIElement</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2016 Thomas Denney. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

View File

@ -0,0 +1,21 @@
#import <Foundation/Foundation.h>
@class Uploader;
@protocol UploaderDelegate <NSObject>
- (void)uploader:(Uploader*)uploader transferredFile:(NSString*)file toMicroBit:(NSString*)microbit;
- (void)uploader:(Uploader*)uploader failedToTransferFile:(NSString*)file toMicroBit:(NSString*)microbit;
@end
@interface Uploader : NSObject
@property id<UploaderDelegate> delegate;
- (BOOL)shouldUploadFileAtPath:(NSString*)path;
- (NSArray<NSString*>*)microBitPaths;
- (void)uploadFile:(NSString*)file;
- (void)uploadFile:(NSString*)file toMicroBit:(NSString*)path;
@end

View File

@ -0,0 +1,74 @@
#import "Uploader.h"
@interface Uploader ()
@property NSOperationQueue * backgroundCopyQueue;
@end
@implementation Uploader
- (instancetype)init {
self = [super init];
if (self) {
self.backgroundCopyQueue = [NSOperationQueue new];
}
return self;
}
- (BOOL)shouldUploadFileAtPath:(NSString *)path {
//Whilst Safari is downloading the file it appends .download to the name
NSRegularExpression * ignoreDownload = [NSRegularExpression regularExpressionWithPattern:@".download$" options:NSRegularExpressionCaseInsensitive error:nil];
if ([ignoreDownload numberOfMatchesInString:path.lastPathComponent options:0 range:NSMakeRange(0, path.lastPathComponent.length)] > 0) {
return NO;
}
//Chrome and Firefox create .hex files
NSRegularExpression * hexFiles = [NSRegularExpression regularExpressionWithPattern:@".hex$" options:NSRegularExpressionCaseInsensitive error:nil];
if ([hexFiles numberOfMatchesInString:path.lastPathComponent options:0 range:NSMakeRange(0, path.lastPathComponent.length)] > 0) {
return YES;
}
//Safari tends to just name files 'Unknown X'
NSRegularExpression * unknownFiles = [NSRegularExpression regularExpressionWithPattern:@"^Unknown(( |-)[0-9]+)?" options:NSRegularExpressionCaseInsensitive error:nil];
if ([unknownFiles numberOfMatchesInString:path.lastPathComponent options:0 range:NSMakeRange(0, path.lastPathComponent.length)]) {
return YES;
}
return NO;
}
- (NSArray<NSString*>*)microBitPaths {
NSArray<NSURL*>* allVolumes = [[NSFileManager defaultManager] mountedVolumeURLsIncludingResourceValuesForKeys:nil options:NSVolumeEnumerationSkipHiddenVolumes];
NSMutableArray<NSString*>* microbitPaths = [NSMutableArray new];
NSRegularExpression * microbitRegex = [NSRegularExpression regularExpressionWithPattern:@"^MICROBIT" options:NSRegularExpressionCaseInsensitive error:nil];
for (NSURL * volume in allVolumes) {
NSString * lastPathComponent = volume.lastPathComponent;
if ([microbitRegex numberOfMatchesInString:lastPathComponent options:0 range:NSMakeRange(0, lastPathComponent.length)] > 0) {
[microbitPaths addObject:volume.path];
}
}
return microbitPaths;
}
- (void)uploadFile:(NSString *)file {
for (NSString * microbit in [self microBitPaths]) {
[self uploadFile:file toMicroBit:microbit];
}
}
- (void)uploadFile:(NSString *)file toMicroBit:(NSString *)path {
[self.backgroundCopyQueue addOperationWithBlock:^{
NSError * copyError;
NSString * destination = [path stringByAppendingPathComponent:file.lastPathComponent];
if (![[NSFileManager defaultManager] copyItemAtPath:file toPath:destination error:&copyError]) {
[self.delegate uploader:self failedToTransferFile:file toMicroBit:path.lastPathComponent];
}
else {
[self.delegate uploader:self transferredFile:file toMicroBit:path.lastPathComponent];
}
}];
}
@end

View File

@ -0,0 +1,5 @@
#import <Cocoa/Cocoa.h>
int main(int argc, const char * argv[]) {
return NSApplicationMain(argc, argv);
}

View File

@ -0,0 +1,40 @@
# micro:bit uploader for OS X
![](Microbit Uploader/Assets.xcassets/AppIcon.appiconset/icon_256x256.png)
This project is a clone of the [Windows
uploader](https://codethemicrobit.com/uploader), but for OS X. Once launched,
the app runs in your menu bar and will automatically deploy any HEX files to
your `micro:bit`. Like the Windows version, it is compatible with any browser
that can run [codethemicrobit.com](http://codethemicrobit.com).
## Install the built version
1. Download the latest `.zip` release from the `Release` directory
2. Unzip it
3. Drag `Microbit Uploader` to your Applications folder and launch it
## Building
To build the project you'll need a copy of OS X 10.11 or higher and Xcode 8 or
higher (you may be able to build on earlier OSes or versions of Xcode, but this
remains untested). Once you have a development environment set up, just build
and run `Microbit Uploader.xcodeproj`.
## Distributing
1. Open the Xcode project
2. Product > Archive
3. Export:
![Export](Graphics/export.png)
4. You will then have the option of either signing or not-signing the
application:
a) If you have an Apple developer account, select 'Export a Developer
ID-signed Application'
b) If you don't have a developer ID, select 'Export as a macOS App'
5. Zip the produced app and upload to CDN or equivalent

Binary file not shown.

View File

@ -13,22 +13,25 @@ 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[]> {
if (process.platform == "win32") {
let rx = new RegExp("^([A-Z]:).* " + pxt.appTarget.compile.deployDrives)
const rx = new RegExp("^([A-Z]:).* " + pxt.appTarget.compile.deployDrives)
return execAsync("wmic PATH Win32_LogicalDisk get DeviceID, VolumeName, FileSystem")
.then(buf => {
let res: string[] = []
@ -42,9 +45,14 @@ function getBitDrivesAsync(): Promise<string[]> {
})
}
else if (process.platform == "darwin") {
let rx = new RegExp(pxt.appTarget.compile.deployDrives)
const rx = new RegExp(pxt.appTarget.compile.deployDrives)
return readDirAsync("/Volumes")
.then(lst => lst.filter(s => rx.test(s)).map(s => "/Volumes/" + s + "/"))
} else if (process.platform == "linux") {
const rx = new RegExp(pxt.appTarget.compile.deployDrives)
const user = process.env["USER"]
return readDirAsync(`/media/${user}`)
.then(lst => lst.filter(s => rx.test(s)).map(s => `/media/${user}/${s}/`))
} else {
return Promise.resolve([])
}

View File

@ -0,0 +1,6 @@
<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", { disable_persistence: true });
if (typeof pxtConfig !== "undefined") mixpanel.register({ target: pxtConfig.targetId, version: pxtConfig.targetVersion });
</script>

View File

@ -19,10 +19,3 @@
<link rel="shortcut icon" href="@appLogo@">
<meta name="theme-color" content="@accentColor@">
<style>
#root .avatar .avatar-image {
background-image: url(https://az851932.vo.msecnd.net/pub/jovrytni/microbit.simplified.svg);
background-size: contain;
background-repeat: no-repeat;
}
</style>

5
docfiles/target.css Normal file
View File

@ -0,0 +1,5 @@
#root .avatar .avatar-image {
background-image: url(https://az851932.vo.msecnd.net/pub/jovrytni/microbit.simplified.svg);
background-size: contain;
background-repeat: no-repeat;
}

View File

@ -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>

View File

@ -1,3 +1,50 @@
![](/static/mb/device/pano.jpg)
# About
### @description A Blocks / Javascript code editor for the micro:bit, a pocket-size computer with 5x5 display, sensors and Bluetooth.
The [BBC micro:bit](https://www.microbit.co.uk) is a [pocket-size computer](/device) with a 5x5 display of 25 LEDs, Bluetooth and sensors that can be programmed by anyone.
The BBC micro:bit was made possible by many [partners](https://www.microbit.co.uk/partners).
The micro:bit provides an easy and fun introduction to programming and making switch on, program it to do something fun wear it, customize it.
Just like Arduino, the micro:bit can be connected to and interact with sensors, displays, and other devices.
* [Read the docs](/docs)
## [Hardware: The Device](/device)
The BBC micro:bit is packaged with sensors, radio and other goodies. Learn about the [hardware components](/device) of the micro:bit to make the most of it!
## Programming: [Blocks](/blocks) or [JavaScript](/javascript)
You can program the micro:bit using [Blocks](/blocks) or [JavaScript](/javascript) in your web browser via the [micro:bit APIs](/reference):
```block
input.onButtonPressed(Button.A, () => {
basic.showString("Hi!");
})
```
```typescript
input.onButtonPressed(Button.A, () => {
basic.showString("Hi!");
})
```
The editor work in [most modern browsers](/browsers), work [offline](/offline) once loaded and do not require any installation.
## [Compile and Flash: Your Program!](/device/usb)
When you have your code ready, you connect your micro:bit to a computer via a USB cable, so it appears as a mounted drive (named MICROBIT).
Compilation to ARM thumb machine code from [Blocks](/blocks) or [JavaScript](/javascript) happens in the browser. You save the ARM binary
program to a file, which you then copy to the micro:bit drive, which flashes the micro:bit device with the new program.
## Simulator: Test Your Code
You can run your code using the micro:bit simulator, all within the confines of a web browser.
The simulator has support for the LED screen, buttons, as well as compass, accelerometer, and digital I/O pins.
```sim
basic.forever(() => {
basic.showString("Hi!");
@ -20,43 +67,8 @@ input.onButtonPressed(Button.B, () => {
. # . # .
. . # . .`);
});
```
# About
### @description A Blocks / Javascript code editor for the micro:bit, a pocket-size computer with 5x5 display, sensors and Bluetooth.
The [BBC micro:bit](https://www.microbit.co.uk) is a [pocket-size computer](/device) with a 5x5 display of 25 LEDs, Bluetooth and sensors that can be programmed by anyone.
The BBC micro:bit was made possible by many [partners](https://www.microbit.co.uk/partners).
The micro:bit provides an easy and fun introduction to programming and making switch on, program it to do something fun wear it, customize it.
Just like Arduino, the micro:bit can be connected to and interact with sensors, displays, and other devices.
## Hardware: The Device
Learn about the [hardware components](/device) of the micro:bit to make the most of it!
## Programming: Blocks or JavaScript
You can program the micro:bit using [Blocks](/blocks) or [JavaScript](/javascript), via the [micro:bit APIs](/reference):
```blocks
input.onButtonPressed(Button.A, () => {
basic.showString("Hi!");
})
```
## Compile and Flash: Your Program!
When you have your code ready, you connect your micro:bit to a computer via a USB cable, so it appears as a mounted drive (named MICROBIT).
Compilation to ARM thumb machine code from [Blocks](/blocks) or [JavaScript](/javascript) happens in the browser. You save the ARM binary
program to a file, which you then copy to the micro:bit drive, which flashes the micro:bit device with the new program.
## Simulator: Test Your Code
You can run your code using the micro:bit simulator, all within the confines of a web browser.
The simulator has support for the LED screen, buttons, as well as compass, accelerometer, and digital I/O pins.
## C++ Runtime
The [C++ micro:bit runtime](http://lancaster-university.github.io/microbit-docs/), created at [Lancaster University](http://www.lancaster.ac.uk/), provides access to the hardware functions of the micro:bit,
@ -65,6 +77,15 @@ as well as a set of helper functions (such as displaying a number/image/string o
The [micro:bit library](/reference) mirrors the functions of the C++ library.
When code is compiled to ARM machine code, the calls to JavaScript micro:bit functions are replaced with calls to the corresponding C++ functions.
## Open Source
## [Command Line Tools](/cli)
Looking to use codethemicrobit.com in your favorite editor? Install the [command line tools](/cli) and get rolling!
## [Packages](/packages)
Create, edit and distribute your own blocks and JavaScript using [packages](/packages). Packages are hosted on GitHub and may be written
using C++, JavaScript and/or ARM thumb.
## [Open Source](/open-source)
The code for the micro:bit is [open source](/open-source) on GitHub. Contributors are welcome!

104
docs/browsers.md Normal file
View File

@ -0,0 +1,104 @@
# Unsupported configuration
[codethemicrobit.com](https://codethemicrobit.com) doesn't currently support
your browser or operating system. The following configurations are supported:
## Windows
You need one of these browsers running on Windows 7, Windows 8, Windows 8.1, or
Windows 10:
* Internet Explorer 11
* Microsoft Edge
* Google Chrome
* Mozilla Firefox
## Mac
You need one of these browsers running on OS X 10.9 Mavericks, OS X 10.10
Yosemite, OS X 10.11 El Capitan, or macOS 10.12 Sierra:
* Safari
* Google Chrome
* Mozilla Firefox
## Linux
If you're using a Raspberry Pi, please see [the documentation
here](/raspberry-pi).
You need to be running a Linux distribution recent enough to run the most recent
version of one of the following:
* Google Chrome, or Chromium
* Mozilla Firefox, Iceweasel, or Seamonkey
## How to check your OS or browser
### Windows
* Click on the Start menu
* Type 'System'
* Click on the app called 'System'
* The version of Windows you are using will be displayed:
![](/static/configurations/windows-version.png)
### Mac
* Click on the Apple icon in the top left
* Click on 'About this Mac'
* This window will be displayed:
![](/static/configurations/osx-version.png)
### Internet Explorer
* Click on the Settings icon in the top right
* Click 'About Internet Explorer'
* This window will be displayed:
![](/static/configurations/ie-version.png)
### Edge
Edge automatically updates, so you should always be using the latest version
* Click on the menu icon in the top right (three dots)
* Scroll to the bottom
* Information similar to the following will be displayed:
![](/static/configurations/edge-version.png)
### Google Chrome
Google Chrome automatically updates, so you should always be using the latest version
* Click on the menu icon in the top right (three dots)
* Click Help, and About Google Chrome
* Information similar to the following will be displayed:
![](/static/configurations/chrome-version.png)
### Firefox
Firefox automatically updates, so you should always be using the latest version
* Click on the menu icon in the top right (three horizontal lines)
* Click the question mark icon (help button)
* Click 'About Firefox'
![](/static/configurations/firefox-version.png)
### Safari
Safari updates when your operating system updates, so if you are using the
latest version of OS X then you'll be using the latest version of Safari.
* Click on the Safari menu in the top left
* Click 'About Safari'
![](/static/configurations/safari-version.png)
IT administrators should check which browser versions are supported
[here](/browsers/technical).

16
docs/browsers/linux.md Normal file
View File

@ -0,0 +1,16 @@
# Recommended browser for Linux
As you are using Linux, it is recommended that you use [Mozilla
Firefox][firefox] or [Google Chrome][chrome].
Please see [here][technical] for technical information on which browsers are
supported, or [here][versions] to check which version you are using.
[edge]: https://www.microsoft.com/en-us/windows/microsoft-edge
[ie]: https://www.microsoft.com/en-us/download/internet-explorer.aspx
[firefox]: https://www.mozilla.org/en-US/firefox/new/
[chrome]: https://www.google.com/chrome/
[opera]: https://www.opera.com
[safari]: http://www.apple.com/safari/
[technical]: /browsers/technical
[versions]: /browsers

16
docs/browsers/mac.md Normal file
View File

@ -0,0 +1,16 @@
# Recommended browser for Mac
As you are using a Mac, it is recommended that you use [Safari][]. Alternatively,
[Google Chrome][chrome] and [Mozilla Firefox][firefox] are also supported.
Please see [here][technical] for technical information on which browsers are
supported, or [here][versions] to check which version you are using.
[edge]: https://www.microsoft.com/en-us/windows/microsoft-edge
[ie]: https://www.microsoft.com/en-us/download/internet-explorer.aspx
[firefox]: https://www.mozilla.org/en-US/firefox/new/
[chrome]: https://www.google.com/chrome/
[opera]: https://www.opera.com
[safari]: http://www.apple.com/safari/
[technical]: /browsers/technical
[versions]: /browsers

View File

@ -0,0 +1,36 @@
# Technical information about browser support
[codethemicrobit.com][] requires that you use a recent version of a modern
browser, such as Microsoft Edge, Google Chrome, Mozilla Firefox, Safari, Opera,
or IE11. This is because the editor uses modern web technologies such as [web
workers][] to enable compiling [TypeScript][] in the browser, or the using the
same [Monaco][] editor that powers [Visual Studio Code][].
[codethemicrobit.com]: https://codethemicrobit.com
[web workers]: http://www.w3.org/TR/workers/
[typescript]: http://www.typescriptlang.org
[monaco]: https://microsoft.github.io/monaco-editor/
[visual studio code]: http://code.visualstudio.com
Most modern browsers automatically update themselves, but in some environments
such as schools these automatic updates are disabled for security. **We
strongly recommend that you use the most recent version of any of these
browsers**, but if you can't then you must use at least:
| Browser | Minimum version | Release date | Windows | Mac |
| ----------------- | --------------- | -------------- | ----------- | ---------- |
| Edge | 12 | March 2015 | Windows 10+ | N/A |
| Internet Explorer | 11 | October 2013 | Windows 7+ | N/A |
| Mozilla Firefox | 31 ESR | July 2014 | Windows XP+ | OS X 10.6+ |
| Google Chrome | 38 | October 2014 | Windows XP+ | OS X 10.6+ |
| Safari | 9 | September 2015 | N/A | OS X 10.9+ |
| Opera | 21 | May 2014 | Windows 7+ | OS X 10.9+ |
Please see our information for which browsers are recommended for [Windows][],
[Mac][], [Linux][], or [Raspberry Pi][].
[Windows]: /browsers/windows
[Mac]: /browsers/mac
[Linux]: /browsers/linux
[Raspberry Pi]: /raspberry-pi

18
docs/browsers/windows.md Normal file
View File

@ -0,0 +1,18 @@
# Recommended browser for Windows
We recommend [Microsoft Edge][edge] if you are running Windows 10, but users on
Windows 7 or higher can use [Internet Explorer 11][ie] or recent versions of
[Mozilla Firefox][firefox], [Google Chrome][chrome], or [Opera][opera].
Please see [here][technical] for technical information on which browsers are
supported, or [here][versions] to check which version you are using.
[edge]: https://www.microsoft.com/en-us/windows/microsoft-edge
[ie]: https://www.microsoft.com/en-us/download/internet-explorer.aspx
[firefox]: https://www.mozilla.org/en-US/firefox/new/
[chrome]: https://www.google.com/chrome/
[opera]: https://www.opera.com
[safari]: http://www.apple.com/safari/
[technical]: /browsers/technical
[versions]: /browsers

View File

@ -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.
![](/static/mb/device/croc-clips/crocclipsclamped.jpg)
Pass one jaw in the hole and grab the side of the board with the other jaw.
![](/static/mb/device/croc-clips/sideclamp.jpg)
For the center holes, ``P1`` and ``P2``, you can also grab the bottom of the board but they are a bit harder to grip.
You can also grip the board between the jaws. In which case, you will want to make sure to avoid overlapping the jaws
with the other pins as it will create short-circuit in the board.
![](/static/mb/device/croc-clips/badclamp.jpg)
Adding a little tape helps keeping the crocodile clips in place.
![](/static/mb/device/croc-clips/frontclamp.jpg)
## Example: on pin pressed with random numbers
This example displays a random number every time the crocodile clip holds `GND` then connects and disconnects the `P0` pin.
Each time the crocodile clip is firmly connected and disconnected from pin `P0`, the micro:bit will return a random Number between 0 and the parameter limit.
```blocks
input.onPinPressed(TouchPin.P0, () => {
@ -13,11 +42,6 @@ input.onPinPressed(TouchPin.P0, () => {
})
```
### Connecting Crocodile Clips
![](/static/mb/crocodile-clips-2.jpg)
### See also
[micro:bit pins](/device/pins), [pin is pressed](/reference/input/pin-is-pressed), [analog read pin](/reference/pins/analog-read-pin), [analog write pin](/reference/pins/analog-write-pin), [digital read pin](/reference/pins/digital-read-pin), [digital write pin](/reference/pins/digital-write-pin)
## See also
[micro:bit pins](/device/pins)

View File

@ -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:

View File

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

View File

@ -1,132 +1,31 @@
# Run Scripts on your micro:bit
# Uploading programs on your micro:bit
How to compile, transfer, and run a script on your micro:bit.
While you're writing and testing your programs, you'll mostly be [running them
in the simulator](/device/simulator), but once you've finished your program you
can **compile** it and run it on your micro:bit.
While you're writing and testing your scripts, you'll mostly be running scripts in your browser by clicking the `PLay` button
(see [run code in your browser](/device/simulator) for info about this).
The basic steps are:
Once your masterpiece is complete, you can compile your script and run it on your micro:bit.
1. Connect your micro:bit to your computer via USB
2. Click **Download** and download the `.hex` file
3. Copy the `.hex` file from your computer onto the micro:bit drive
## Requirements
![](/static/mb/device/usb-thin.jpg)
You need the following things to transfer and run a script on your micro:bit:
## Instructions
* A-Male to Micro USB cable to connect your computer to your micro:bit. This is the same cable that is commonly used to connect a smart phone to a computer.
* a PC running Windows 7 of later, or a Mac running OS X 10.6 or later
* access to the Internet
Pick the instructions for your operating system and browser:
## Step 1: Connect your micro:bit to your computer
* [Windows - Microsoft Edge](/device/usb/windows-edge)
* [Windows - Internet Explorer](/device/usb/windows-ie)
* [Windows - Chrome](/device/usb/windows-chrome)
* [Windows - Firefox](/device/usb/windows-firefox)
* [Mac - Safari](/device/usb/mac-safari)
* [Mac - Chrome](/device/usb/mac-chrome)
* [Mac - Firefox](/device/usb/mac-firefox)
First, connect the micro:bit:
### ~hint
1. Connect the small end of the USB cable to the micro USB port on your micro:bit.
2. Connect the other end of the USB cable to a USB port on your computer.
Your computer should recognise your micro:bit as a new drive. On computers running Windows, MICROBIT appears as a drive under Devices and drives. On a Mac it appears as a new drive under Devices.
Windows
![](/static/mb/device/usb-0.jpg)
Mac (picture bvabdbco)
WARN: unknown picture: bvabdbco:5x3
## Step 2: Compile your script
Next, compile your script:
1. Sign in to Touch Develop on your computer.
2. Open your script (find the script in **My Scripts** and click `Edit`).
3. Click **Download**. Your script is converted into a hex file that you can transfer and run on your micro:bit.
4. When prompted, choose to save the compiled file on your computer (or anywhere other than the micro:bit). Depending on which browser you are using, the download will adopt the download behaviour of that particular browser.
### Windows
** Chrome**
Your .hex file appears as a download at the bottom of the browser. Open up your windows file explorer. Your micro:bit appears as a drive called MICROBIT.
**Right click** on the download and select **show in folder**. Drag and drop the hex file from the download folder onto the MICROBIT drive.
Alternatively, you can drag and drop the downloaded hex file from the bottom of the browser onto the file explorer and onto the MICROBIT drive.
![](/static/mb/device/usb-1.jpg)
**Firefox**
A dialogue box will appear, asking whether you would like to open or save your hex file. Select **Save**, then **OK** and the file will appear in your downloads in the top right of your browser. Select the **blue arrow**, select the relevant file and drag and drop it onto your Windows Explorer and onto your MICROBIT drive.
![](/static/mb/device/usb-2.jpg)
![](/static/mb/device/usb-3.jpg)
**IE10**
Click on **Download**. You will see a message “Do you want to save this .hex file.” Select **Save**.
### Mac
** Safari**
When you select **Download** in Safari on Mac, your file will be downloaded to your downloads folder. Go to your downloads folder and open the file. In Safari the file will appear as unknown.txt rather than a named .hex file. Drag and drop it onto your MICROBIT drive.
![](/static/mb/device/usb-4.jpg)
**Firefox**
A dialogue box will appear, asking whether you would like to open or save your hex file. Select **Save** and **OK** and the file will then appear in your downloads in the top right of your browser. Click on **Show in Finder** and the file will appear in your downloads folder. Select the file and drag and drop it onto your MICROBIT drive.
![](/static/mb/device/usb-5.jpg)
![](/static/mb/device/usb-6.jpg)
**Chrome**
When you select **Download** in Chrome, the file will be downloaded to the bottom of the browser in .hex format. Click on the small arrow and select **Show in Finder**. This will show the file in your download folder. Drag and drop the file onto your MICROBIT drive.
![](/static/mb/device/usb-7.jpg)
## Step 3: Transfer the file to your micro:bit
1. The file will transfer onto your micro:bit.
2. If you're using Windows, you can use **Send to** as described below.
3. The LED on the back of your micro:bit flashes during the transfer (which should only take a few seconds).
4. Once transferred, the code will run automatically on your micro:bit. To rerun your program, press the reset button on the back of your micro:bit. The reset button automatically runs the newest file on the micro:bit.
**Send to**: If you're using Windows you use *Send to* in File Explorer:
- In File Explorer, right-click on the hex file (created in Step 2 above), choose **Send to**, and then **MICROBIT**.
![](/static/mb/device/usb-8.jpg)
By copying the script onto the 'MICROBIT' drive, you have programmed it into the flash memory on the micro:bit, which means even after you unplug the micro:bit, your script will still run if the micro:bit is powered by battery.
## Troubleshooting
You cant drag and drop more than one hex file at once onto your micro:bit. If you try to drag and drop a second hex file onto your micro:bit before the first file has finished downloading, then the second file may fail in different ways.
When the first program has been written to the micro:bit, the drive will disengage. If you drag and drop a second file at this point it may not find the drive and the second write will fail.
The errors may look like this:
**Windows**
![](/static/mb/device/usb-9.jpg)
**Mac**
![](/static/mb/device/usb-10.png)
Or it may appear that there are two hex files on your micro:bit so the micro:bit wont be able to run multiple files. To rectify this, unplug your micro:bit and plug it in again. Make sure that your micro:bit appears as MICROBIT and not MAINTENANCE.
### See also
[Run code in a browser](/device/simulator)
Transfer not working? See some [troubleshooting tips](/device/usb/troubleshooting).
### ~

View File

@ -0,0 +1,69 @@
# Uploading from Chrome for Mac
While you're writing and testing your programs, you'll mostly be [running them
in the simulator](/device/simulator), but once you've finished your program you
can **compile** it and run it on your micro:bit.
The basic steps are:
1. Connect your micro:bit to your computer via USB
2. Click **Download** and download the `.hex` file
3. Copy the `.hex` file from your computer onto the micro:bit drive
## Requirements
You need the following things to transfer and run a script on your micro:bit:
* A-Male to Micro USB cable to connect your computer to your micro:bit. This is
the same cable that is commonly used to connect a smart phone to a computer.
* A PC running Windows 7 or later, or a Mac running OS X 10.6 or later
## Step 1: Connect your micro:bit to your computer
First, connect the micro:bit:
1. Connect the small end of the USB cable to the micro USB port on your micro:bit.
2. Connect the other end of the USB cable to a USB port on your computer.
Your computer should recognise your micro:bit as a new drive. On computers
running Windows, `MICROBIT` appears as a drive under Devices and drives. On a Mac
it appears as a new drive under Devices.
![](/static/mb/device/usb-osx-device.png)
## Step 2: Download your program
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com)
2. Click **Download**
3. When prompted, choose to **save** the compiled file onto your computer. The
prompt will be different depending on which browser you are using, or
whether you are using a Windows computer or a Mac
When you select **Download** in Chrome, the file will appear at the bottom of
the browser. Click on the small arrow and select **Show in Finder**. This will
show the file in your download folder. Drag and drop the file onto your
`MICROBIT` drive.
![](/static/mb/device/usb-osx-chrome.png)
## Step 3: Transfer the file to your micro:bit
* Once you've found the folder containing your `.hex` file, drag and drop it
onto your `MICROBIT` drive
* The LED on the back of your micro:bit flashes during the transfer (which
should only take a few seconds).
* Once transferred, the code will run automatically on your micro:bit. To rerun
your program, press the reset button on the back of your micro:bit. The reset
button automatically runs the newest file on the micro:bit.
By copying the script onto the `MICROBIT` drive, you have programmed it into the
flash memory on the micro:bit, which means even after you unplug the micro:bit,
your program will still run if the micro:bit is powered by battery.
### ~hint
Transfer not working? See some [troubleshooting tips](/device/usb/troubleshooting).
### ~

View File

@ -0,0 +1,71 @@
# Uploading from Firefox for Mac
While you're writing and testing your programs, you'll mostly be [running them
in the simulator](/device/simulator), but once you've finished your program you
can **compile** it and run it on your micro:bit.
The basic steps are:
1. Connect your micro:bit to your computer via USB
2. Click **Download** and download the `.hex` file
3. Copy the `.hex` file from your computer onto the micro:bit drive
## Requirements
You need the following things to transfer and run a script on your micro:bit:
* A-Male to Micro USB cable to connect your computer to your micro:bit. This is
the same cable that is commonly used to connect a smart phone to a computer.
* A PC running Windows 7 or later, or a Mac running OS X 10.6 or later
## Step 1: Connect your micro:bit to your computer
First, connect the micro:bit:
1. Connect the small end of the USB cable to the micro USB port on your micro:bit.
2. Connect the other end of the USB cable to a USB port on your computer.
Your computer should recognise your micro:bit as a new drive. On computers
running Windows, `MICROBIT` appears as a drive under Devices and drives. On a Mac
it appears as a new drive under Devices.
![](/static/mb/device/usb-osx-device.png)
## Step 2: Download your program
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com)
2. Click **Download**
3. When prompted, choose to **save** the compiled file onto your computer. The
prompt will be different depending on which browser you are using, or
whether you are using a Windows computer or a Mac
A dialogue box will appear, asking whether you would like to open or save your
hex file. Select **Save file** and click **OK** and the file will then appear in
your downloads in the top right of your browser. Right click on the file and
click on **Show in Finder** and the file will appear in your downloads folder.
Select the file and drag and drop it onto your `MICROBIT` drive.
![](/static/mb/device/usb-osx-firefox-1.jpg)
![](/static/mb/device/usb-osx-firefox-2.png)
## Step 3: Transfer the file to your micro:bit
* Once you've found the folder containing your `.hex` file, drag and drop it
onto your `MICROBIT` drive
* The LED on the back of your micro:bit flashes during the transfer (which
should only take a few seconds).
* Once transferred, the code will run automatically on your micro:bit. To rerun
your program, press the reset button on the back of your micro:bit. The reset
button automatically runs the newest file on the micro:bit.
By copying the script onto the `MICROBIT` drive, you have programmed it into the
flash memory on the micro:bit, which means even after you unplug the micro:bit,
your program will still run if the micro:bit is powered by battery.
### ~hint
Transfer not working? See some [troubleshooting tips](/device/usb/troubleshooting).
### ~

View File

@ -0,0 +1,68 @@
# Uploading from Safari for Mac
While you're writing and testing your programs, you'll mostly be [running them
in the simulator](/device/simulator), but once you've finished your program you
can **compile** it and run it on your micro:bit.
The basic steps are:
1. Connect your micro:bit to your computer via USB
2. Click **Download** and download the `.hex` file
3. Copy the `.hex` file from your computer onto the micro:bit drive
## Requirements
You need the following things to transfer and run a script on your micro:bit:
* A-Male to Micro USB cable to connect your computer to your micro:bit. This is
the same cable that is commonly used to connect a smart phone to a computer.
* A PC running Windows 7 or later, or a Mac running OS X 10.6 or later
## Step 1: Connect your micro:bit to your computer
First, connect the micro:bit:
1. Connect the small end of the USB cable to the micro USB port on your micro:bit.
2. Connect the other end of the USB cable to a USB port on your computer.
Your computer should recognise your micro:bit as a new drive. On computers
running Windows, `MICROBIT` appears as a drive under Devices and drives. On a Mac
it appears as a new drive under Devices.
![](/static/mb/device/usb-osx-device.png)
## Step 2: Download your program
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com)
2. Click **Download**
3. When prompted, choose to **save** the compiled file onto your computer. The
prompt will be different depending on which browser you are using, or
whether you are using a Windows computer or a Mac
When you select **Download** in Safari a file called `Unknown` will be
downloaded into your Downloads folder. Open your Downloads folder and drag and
drop the file onto your `MICROBIT` drive, under Devices:
![](/static/mb/device/usb-osx-dnd.png)
## Step 3: Transfer the file to your micro:bit
* Once you've found the folder containing your `.hex` file, drag and drop it
onto your `MICROBIT` drive
* The LED on the back of your micro:bit flashes during the transfer (which
should only take a few seconds).
* Once transferred, the code will run automatically on your micro:bit. To rerun
your program, press the reset button on the back of your micro:bit. The reset
button automatically runs the newest file on the micro:bit.
By copying the script onto the `MICROBIT` drive, you have programmed it into the
flash memory on the micro:bit, which means even after you unplug the micro:bit,
your program will still run if the micro:bit is powered by battery.
### ~hint
Transfer not working? See some [troubleshooting tips](/device/usb/troubleshooting).
### ~

View File

@ -0,0 +1,24 @@
# Troubleshooting Transfer
You cant drag and drop more than one hex file at once onto your micro:bit. If
you try to drag and drop a second hex file onto your micro:bit before the first
file has finished downloading, then the second file may fail in different ways.
When the first program has been written to the micro:bit, the drive will
disengage. If you drag and drop a second file at this point it may not find the
drive and the second write will fail.
The errors may look like this:
**Windows**
![](/static/mb/device/usb-windows-copy-file-error.jpg)
**Mac**
![](/static/mb/device/usb-osx-copy-file-error.png)
Or it may appear that there are two hex files on your micro:bit so the micro:bit
wont be able to run multiple files. To rectify this, unplug your micro:bit and
plug it in again. Make sure that your micro:bit appears as `MICROBIT` and not
`MAINTENANCE`.

View File

@ -0,0 +1,79 @@
# Uploading from Chrome for Windows
While you're writing and testing your programs, you'll mostly be [running them
in the simulator](/device/simulator), but once you've finished your program you
can **compile** it and run it on your micro:bit.
The basic steps are:
1. Connect your micro:bit to your computer via USB
2. Click **Download** and download the `.hex` file
3. Copy the `.hex` file from your computer onto the micro:bit drive
### ~hint
You can use the [micro:bit uploader](/uploader) to automatically deploy ``.hex`` files to your micro:bit!
![](/static/uploader/tooltip.png)
### ~
## Requirements
You need the following things to transfer and run a script on your micro:bit:
* A-Male to Micro USB cable to connect your computer to your micro:bit. This is
the same cable that is commonly used to connect a smart phone to a computer.
* A PC running Windows 7 or later, or a Mac running OS X 10.6 or later
## Step 1: Connect your micro:bit to your computer
First, connect the micro:bit:
1. Connect the small end of the USB cable to the micro USB port on your micro:bit.
2. Connect the other end of the USB cable to a USB port on your computer.
Your computer should recognise your micro:bit as a new drive. On computers
running Windows, `MICROBIT` appears as a drive under Devices and drives. On a Mac
it appears as a new drive under Devices.
![](/static/mb/device/usb-windows-device.jpg)
## Step 2: Download your program
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com)
2. Click **Download**
3. When prompted, choose to **save** the compiled file onto your computer. The
prompt will be different depending on which browser you are using, or
whether you are using a Windows computer or a Mac
Your `.hex` file appears as a download at the bottom of the browser. Click on
the arrow next to the name of the file and then click **Show in folder**.
![](/static/mb/device/usb-windows-chrome.png)
Drag and drop the `.hex` file from the download folder onto the `MICROBIT` drive.
## Step 3: Transfer the file to your micro:bit
* Once you've found the folder containing your `.hex` file, drag and drop it
onto your `MICROBIT` drive
* The LED on the back of your micro:bit flashes during the transfer (which
should only take a few seconds).
* Once transferred, the code will run automatically on your micro:bit. To rerun
your program, press the reset button on the back of your micro:bit. The reset
button automatically runs the newest file on the micro:bit.
In File Explorer, right-click on the hex file (created in Step 2 above), choose **Send to**, and then **MICROBIT**.
![](/static/mb/device/usb-windows-sendto.jpg)
By copying the script onto the `MICROBIT` drive, you have programmed it into the
flash memory on the micro:bit, which means even after you unplug the micro:bit,
your program will still run if the micro:bit is powered by battery.
### ~hint
Transfer not working? See some [troubleshooting tips](/device/usb/troubleshooting).
### ~

View File

@ -0,0 +1,89 @@
# Uploading from Edge on Windows
How to compile, transfer, and run a program on your micro:bit on **Microsoft Edge**.
While you're writing and testing your programs, you'll mostly be [running them
in the simulator](/device/simulator), but once you've finished your program you
can **compile** it and run it on your micro:bit.
The basic steps are:
1. Connect your micro:bit to your computer via USB
2. Click **Download** and download the `.hex` file
3. Copy the `.hex` file from your computer onto the micro:bit drive
### ~hint
You can use the [micro:bit uploader](/uploader) to automatically deploy ``.hex`` files to your micro:bit!
![](/static/uploader/tooltip.png)
### ~
## Requirements
You need the following things to transfer and run a script on your micro:bit:
* A-Male to Micro USB cable to connect your computer to your micro:bit. This is
the same cable that is commonly used to connect a smart phone to a computer.
* A PC running Windows 7 or later, or a Mac running OS X 10.6 or later
## Step 1: Connect your micro:bit to your computer
First, connect the micro:bit:
1. Connect the small end of the USB cable to the micro USB port on your micro:bit.
2. Connect the other end of the USB cable to a USB port on your computer.
Your computer should recognise your micro:bit as a new drive. On computers
running Windows, `MICROBIT` appears as a drive under Devices and drives. On a Mac
it appears as a new drive under Devices.
![](/static/mb/device/usb-windows-device.jpg)
## Step 2: Download your program
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com)
2. Click **Download**
3. When prompted, choose to **save** the compiled file onto your computer. The
prompt will be different depending on which browser you are using, or
whether you are using a Windows computer or a Mac
A message will appear at the bottom of the browser asking what you want to do
with the file. Click **Save**:
![](/static/mb/device/usb-windows-edge-1.png)
Then click **Open folder** and drag and drop the file from your Downloads to
your `MICROBIT` drive.
![](/static/mb/device/usb-windows-edge-2.png)
## Step 3: Transfer the file to your micro:bit
* Once you've found the folder containing your `.hex` file, drag and drop it
onto your `MICROBIT` drive
* If you're using Windows, you can use **Send to** as described below
* The LED on the back of your micro:bit flashes during the transfer (which
should only take a few seconds).
* Once transferred, the code will run automatically on your micro:bit. To rerun
your program, press the reset button on the back of your micro:bit. The reset
button automatically runs the newest file on the micro:bit.
In File Explorer, right-click on the hex file (created in Step 2 above), choose **Send to**, and then **MICROBIT**.
![](/static/mb/device/usb-windows-sendto.jpg)
By copying the script onto the `MICROBIT` drive, you have programmed it into the
flash memory on the micro:bit, which means even after you unplug the micro:bit,
your program will still run if the micro:bit is powered by battery.
If you want to save time, you can use the [micro:bit uploader](/uploader) to
automatically deploy hex files to your micro:bit. It works on Windows and is
compatible with any browser.
### ~hint
Transfer not working? See some [troubleshooting tips](/device/usb/troubleshooting).
### ~

View File

@ -0,0 +1,86 @@
# Uploading from Firefox on Windows
How to compile, transfer, and run a program on your micro:bit on **Firefox for Windows**.
While you're writing and testing your programs, you'll mostly be [running them
in the simulator](/device/simulator), but once you've finished your program you
can **compile** it and run it on your micro:bit.
The basic steps are:
1. Connect your micro:bit to your computer via USB
2. Click **Download** and download the `.hex` file
3. Copy the `.hex` file from your computer onto the micro:bit drive
### ~hint
You can use the [micro:bit uploader](/uploader) to automatically deploy ``.hex`` files to your micro:bit!
![](/static/uploader/tooltip.png)
### ~
## Requirements
You need the following things to transfer and run a script on your micro:bit:
* A-Male to Micro USB cable to connect your computer to your micro:bit. This is
the same cable that is commonly used to connect a smart phone to a computer.
* A PC running Windows 7 or later, or a Mac running OS X 10.6 or later
## Step 1: Connect your micro:bit to your computer
First, connect the micro:bit:
1. Connect the small end of the USB cable to the micro USB port on your micro:bit.
2. Connect the other end of the USB cable to a USB port on your computer.
Your computer should recognise your micro:bit as a new drive. On computers
running Windows, `MICROBIT` appears as a drive under Devices and drives. On a Mac
it appears as a new drive under Devices.
![](/static/mb/device/usb-windows-device.jpg)
## Step 2: Download your program
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com)
2. Click **Download**
3. When prompted, choose to **save** the compiled file onto your computer. The
prompt will be different depending on which browser you are using, or
whether you are using a Windows computer or a Mac
A window will appear asking whether you want to save or open the `.hex` file.
Select **Save File** and then select **OK**.
![](/static/mb/device/usb-windows-firefox-1.png)
The file will then appear in your downloads in the top right of your browser.
Click the **folder icon** next to the filename to open it in Windows Explorer.
![](/static/mb/device/usb-windows-firefox-2.jpg)
Drag and drop the `.hex` file from the download folder onto the `MICROBIT` drive.
## Step 3: Transfer the file to your micro:bit
* Once you've found the folder containing your `.hex` file, drag and drop it
onto your `MICROBIT` drive
* If you're using Windows, you can use **Send to** as described below
* The LED on the back of your micro:bit flashes during the transfer (which
should only take a few seconds).
* Once transferred, the code will run automatically on your micro:bit. To rerun
your program, press the reset button on the back of your micro:bit. The reset
button automatically runs the newest file on the micro:bit.
In File Explorer, right-click on the hex file (created in Step 2 above), choose **Send to**, and then **MICROBIT**.
![](/static/mb/device/usb-windows-sendto.jpg)
By copying the script onto the `MICROBIT` drive, you have programmed it into the
flash memory on the micro:bit, which means even after you unplug the micro:bit,
your program will still run if the micro:bit is powered by battery.
### ~hint
Transfer not working? See some [troubleshooting tips](/device/usb/troubleshooting).
### ~

View File

@ -0,0 +1,86 @@
# Uploading from Internet Explorer on Windows
While you're writing and testing your programs, you'll mostly be [running them
in the simulator](/device/simulator), but once you've finished your program you
can **compile** it and run it on your micro:bit.
The basic steps are:
1. Connect your micro:bit to your computer via USB
2. Click **Download** and download the `.hex` file
3. Copy the `.hex` file from your computer onto the micro:bit drive
### ~hint
You can use the [micro:bit uploader](/uploader) to automatically deploy ``.hex`` files to your micro:bit!
![](/static/uploader/tooltip.png)
### ~
## Requirements
You need the following things to transfer and run a script on your micro:bit:
* A-Male to Micro USB cable to connect your computer to your micro:bit. This is
the same cable that is commonly used to connect a smart phone to a computer.
* A PC running Windows 7 or later, or a Mac running OS X 10.6 or later
## Step 1: Connect your micro:bit to your computer
First, connect the micro:bit:
1. Connect the small end of the USB cable to the micro USB port on your micro:bit.
2. Connect the other end of the USB cable to a USB port on your computer.
Your computer should recognise your micro:bit as a new drive. On computers
running Windows, `MICROBIT` appears as a drive under Devices and drives. On a Mac
it appears as a new drive under Devices.
![](/static/mb/device/usb-windows-device.jpg)
## Step 2: Download your program
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com)
2. Click **Download**
3. When prompted, choose to **save** the compiled file onto your computer. The
prompt will be different depending on which browser you are using, or
whether you are using a Windows computer or a Mac
A message will appear at the bottom of the browser asking what you want to do
with the file. Click **Save**:
![](/static/mb/device/usb-windows-ie11-1.png)
Then click **Open folder** and drag and drop the file from your Downloads to
your `MICROBIT` drive.
![](/static/mb/device/usb-windows-ie11-2.png)
## Step 3: Transfer the file to your micro:bit
* Once you've found the folder containing your `.hex` file, drag and drop it
onto your `MICROBIT` drive
* If you're using Windows, you can use **Send to** as described below
* The LED on the back of your micro:bit flashes during the transfer (which
should only take a few seconds).
* Once transferred, the code will run automatically on your micro:bit. To rerun
your program, press the reset button on the back of your micro:bit. The reset
button automatically runs the newest file on the micro:bit.
**Send to**: If you're using Windows you use *Send to* in File Explorer:
In File Explorer, right-click on the hex file (created in Step 2 above), choose **Send to**, and then **MICROBIT**.
![](/static/mb/device/usb-windows-sendto.jpg)
By copying the script onto the `MICROBIT` drive, you have programmed it into the
flash memory on the micro:bit, which means even after you unplug the micro:bit,
your program will still run if the micro:bit is powered by battery.
### ~hint
Transfer not working? See some [troubleshooting tips](/device/usb/troubleshooting).
### ~

View File

@ -21,6 +21,7 @@
### More questions?
* [Frequently Asked Question](/faq)
* [Embedding project](/share)
* [Help Translate](/translate)
* [Release notes](/release-notes)

View File

@ -18,7 +18,8 @@ to reopen your latest project. You can also open previous project stored locally
The project source is also stored in each compiled ``.hex`` file. Drag and drop the ``.hex`` file into the web editor to load the project.
To share your project with others, you can use the **Embed** feature. It stores your project in the cloud and creates a URL that you can share with others.
To share your project with others, you can use the [Embed Project...](/share).
It stores your project in the cloud and creates a URL that you can share with others.
If you are using [Visual Studio Code](/code), all your programs are stored as files on your computer and you can use your favorite source control system as needed.

View File

@ -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

View File

@ -1,13 +1,13 @@
# happy birthday blocks activity
Play sounds with music blocks.
Play sounds with music blocks.
Have you ever tried to play a song on an instrument? Let's try coding the song "Happy Birthday" on the micro:bit !
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);
```

View File

@ -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));
```

View File

@ -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)

View File

@ -44,7 +44,7 @@ let hero = game.createSprite(2, 2);
let food = game.createSprite(4, 4);
let ghost = game.createSprite(0, 0);
ghost.change(LedSpriteProperty.Blink, 100);
food = led.brightness() == 8;
food.set(LedSpriteProperty.Brightness, 8);
```
@ -56,7 +56,7 @@ let hero = game.createSprite(2, 2);
let food = game.createSprite(4, 4);
let ghost = game.createSprite(0, 0);
ghost.change(LedSpriteProperty.Blink, 100);
food = led.brightness() == 8;
food.set(LedSpriteProperty.Brightness, 8);
while (true) {
basic.pause(400);
}
@ -73,7 +73,7 @@ let hero = game.createSprite(2, 2);
let food = game.createSprite(4, 4);
let ghost = game.createSprite(0, 0);
ghost.change(LedSpriteProperty.Blink, 100);
food = led.brightness() == 8;
food.set(LedSpriteProperty.Brightness, 8);
while (true) {
basic.pause(400);
if (ghost.get(LedSpriteProperty.X) < hero.get(LedSpriteProperty.X)) {
@ -99,7 +99,7 @@ let hero = game.createSprite(2, 2);
let food = game.createSprite(4, 4);
let ghost = game.createSprite(0, 0);
ghost.change(LedSpriteProperty.Blink, 100);
food = led.brightness() == 8;
food.set(LedSpriteProperty.Brightness, 8);
while (true) {
basic.pause(400);
if (ghost.get(LedSpriteProperty.X) < hero.get(LedSpriteProperty.X)) {
@ -127,7 +127,7 @@ let hero = game.createSprite(2, 2);
let food = game.createSprite(4, 4);
let ghost = game.createSprite(0, 0);
ghost.change(LedSpriteProperty.Blink, 100);
food = led.brightness() == 8;
food.set(LedSpriteProperty.Brightness, 8);
while (true) {
basic.pause(400);
if (ghost.get(LedSpriteProperty.X) < hero.get(LedSpriteProperty.X)) {
@ -164,7 +164,7 @@ let hero = game.createSprite(2, 2);
let food = game.createSprite(4, 4);
let ghost = game.createSprite(0, 0);
ghost.change(LedSpriteProperty.Blink, 100);
food = led.brightness() == 8;
food.set(LedSpriteProperty.Brightness, 8);
while (true) {
basic.pause(400);
if (ghost.get(LedSpriteProperty.X) < hero.get(LedSpriteProperty.X)) {
@ -212,7 +212,7 @@ let hero = game.createSprite(2, 2);
let food = game.createSprite(4, 4);
let ghost = game.createSprite(0, 0);
ghost.change(LedSpriteProperty.Blink, 100);
food = led.brightness() == 8;
food.set(LedSpriteProperty.Brightness, 8);
while (true) {
basic.pause(400);
if (ghost.get(LedSpriteProperty.X) < hero.get(LedSpriteProperty.X)) {

View File

@ -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,18 +23,42 @@ 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"
},{
}, {
"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)

View File

@ -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!
### ~
![](/static/mb/lessons/banana-keyboard-0.png)
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
![](/static/mb/lessons/banana-keyboard-1.png)
Using the 1st crocodile clip, connect the end of the crocodile clip onto GND pin on the micro:bit.
### Step 2
![](/static/mb/lessons/banana-keyboard-2.png)
![](/static/mb/lessons/banana-keyboard-3.png)
Using the 2nd crocodile clip, connect the end of the crocodile clip onto the 0 pin on the micro:bit.
### Step 3
![](/static/mb/lessons/banana-keyboard-4.png)
Using the 1st crocodile clip, connect the second end of the crocodile clip onto based of the headphone jack.
### Step 4
![](/static/mb/lessons/banana-keyboard-5.png)
![](/static/mb/lessons/banana-keyboard-6.png)
Using the 2nd crocodile clip, connect the second end of the crocodile clip onto tip of the headphone jack.
### Step 5
![](/static/mb/lessons/banana-keyboard-7.png)
Using the 3rd crocodile clip, connect the end of the crocodile clip onto the 1st crocodile clip already clipped onto GND.
### Step 6
![](/static/mb/lessons/banana-keyboard-8.png)
![](/static/mb/lessons/banana-keyboard-9.png)
Using the 3rd crocodile clip, connect the unattached end of the crocodile clip onto the orange.
### Step 7
![](/static/mb/lessons/banana-keyboard-10.png)
Using the 4th crocodile clip, connect the end of the crocodile clip onto pin 1 on the micro:bit.
### Step 8
![](/static/mb/lessons/banana-keyboard-11.png)
Using the 4th crocodile clip, connect the unattached end of the crocodile clip onto the banana.
### Step 9
![](/static/mb/lessons/banana-keyboard-12.png)
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!
### ~

View File

@ -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.

View File

@ -0,0 +1,85 @@
# banana keyboard - making
## Materials
* micro:bit, battery holder and 2 AAA batteries
* Bananas
* Orange
* Crocodile clips
## Steps
### Step 1
![](/static/mb/lessons/banana-keyboard-1.png)
Using the 1st crocodile clip, connect the end of the crocodile clip onto GND pin on the micro:bit.
### Step 2
![](/static/mb/lessons/banana-keyboard-2.png)
![](/static/mb/lessons/banana-keyboard-3.png)
Using the 2nd crocodile clip, connect the end of the crocodile clip onto the 0 pin on the micro:bit.
### Step 3
![](/static/mb/lessons/banana-keyboard-4.png)
Using the 1st crocodile clip, connect the second end of the crocodile clip onto based of the headphone jack.
### Step 4
![](/static/mb/lessons/banana-keyboard-5.png)
![](/static/mb/lessons/banana-keyboard-6.png)
Using the 2nd crocodile clip, connect the second end of the crocodile clip onto tip of the headphone jack.
### Step 5
![](/static/mb/lessons/banana-keyboard-7.png)
Using the 3rd crocodile clip, connect the end of the crocodile clip onto the 1st crocodile clip already clipped onto GND.
### Step 6
![](/static/mb/lessons/banana-keyboard-8.png)
![](/static/mb/lessons/banana-keyboard-9.png)
Using the 3rd crocodile clip, connect the unattached end of the crocodile clip onto the orange.
### Step 7
![](/static/mb/lessons/banana-keyboard-10.png)
Using the 4th crocodile clip, connect the end of the crocodile clip onto pin 1 on the micro:bit.
### Step 8
![](/static/mb/lessons/banana-keyboard-11.png)
Using the 4th crocodile clip, connect the unattached end of the crocodile clip onto the banana.
### Step 9
![](/static/mb/lessons/banana-keyboard-12.png)
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
### ~

View File

@ -103,7 +103,3 @@ basic.forever(() => {
}
});
```
### ~button /projects/hack-your-headphones
NEXT: Hack Your Headphones
### ~

View File

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

42
docs/projects/guitar.md Normal file
View File

@ -0,0 +1,42 @@
# Guitar
![guitar icon](/static/mb/projects/guitar.png)
### @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!
### ~

View 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.
![micro:bit x, y, z axis image](/static/mb/projects/guitar/accelleration_axis.png)
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**
![Fahrenheit to Celsius](/static/mb/projects/guitar/map_analogy.png "Fahrenheit to Celsius")
### ~
### 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
### ~

View 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
![battery pack and micro:bit](/static/mb/projects/guitar/microbit.jpg)
2 to 4 crocodile clips
![crocodile clips](/static/mb/projects/guitar/crocclips.jpg)
Headphones
![earbud headphones](/static/mb/projects/guitar/headphones.jpg)
## 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
![micro:bit USB connection](/static/mb/projects/guitar/connectmicrobit.jpg)
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
![crocodile clips attached to pins 0 and GND](/static/mb/projects/guitar/crocclipintoboard.jpg)
![crocodile clips attached to headphone jack](/static/mb/projects/guitar/jacktocrocs.jpg)
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
### ~

View 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
### ~

View 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
![Materials: cardboard, tape, scissors, markers](/static/mb/projects/guitar/materials.jpg)
## 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!
![guitar design samples](/static/mb/projects/guitar/otherdesigns.jpg)
## 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
### ~

View 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

View File

@ -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.
### ~
![](/static/mb/lessons/hack-your-headphones-0.png)
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!]()
![](/static/mb/lessons/banana-keyboard-1.png)
# ~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
# ~
![](/static/mb/lessons/banana-keyboard-2.png)
### ~button /projects/hack-your-headphones/making
![](/static/mb/lessons/banana-keyboard-3.png)
Using the 2nd crocodile clip, connect the end of the crocodile clip onto the 0 pin on the micro:bit.
### Step 3
![](/static/mb/lessons/banana-keyboard-4.png)
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
![](/static/mb/lessons/banana-keyboard-5.png)
![](/static/mb/lessons/hack-your-headphones-1.png)
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
![](/static/mb/lessons/hack-your-headphones-0.png)
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!
### ~

View 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
![](/static/mb/lessons/banana-keyboard-1.png)
Using the 1st crocodile clip, connect the end of the crocodile clip onto GND pin on the micro:bit.
### Step 2
![](/static/mb/lessons/banana-keyboard-2.png)
![](/static/mb/lessons/banana-keyboard-3.png)
Using the 2nd crocodile clip, connect the end of the crocodile clip onto the 0 pin on the micro:bit.
### Step 3
![](/static/mb/lessons/banana-keyboard-4.png)
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
![](/static/mb/lessons/banana-keyboard-5.png)
![](/static/mb/lessons/hack-your-headphones-1.png)
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
![](/static/mb/lessons/hack-your-headphones-0.png)
You hacked your headphones!
### ~button /projects/hack-your-headphones/music-of-light
NEXT: music of light
### ~

View File

@ -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
### ~

View File

@ -48,7 +48,3 @@ input.onPinPressed(TouchPin.P2, () => {
`);
});
```
### ~button /projects/rock-paper-scissors
NEXT: Rock Paper Scissors
### ~

View File

@ -58,7 +58,9 @@ After running this simulation several seconds by moving the micro:bit side to si
![](/static/mb/acc2.png)
### ~
Finally, you must open the Excel CSV file by clicking on the data.xls file that was downloaded to Downloads Folder.
Finally, you must open the Excel CSV file by clicking on the `data.csv` file
that was downloaded to Downloads Folder.
![](/static/mb/data3.png)
@ -87,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
```
```

View File

@ -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
### ~

View File

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

View File

@ -1,75 +1,25 @@
# telegraph activity
Build a telgraph.
# micro:bit telegraph
![](/static/mb/lessons/telegraph-0.png)
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
![](/static/mb/lessons/banana-keyboard-1.png)
Using the 1st crocodile clip, connect the end of the crocodile clip onto GND pin on the micro:bit.
### Step 2
![](/static/mb/lessons/ornament-chain-2.png)
Using the 2nd crocodile clip, connect the end of the crocodile clip onto the 3V pin on the micro:bit.
### Step 3
![](/static/mb/lessons/ornament-chain-3.png)
Using the 3rd crocodile clip, connect the end of the crocodile clip onto pin 1 of the micro:bit.
### Step 4
![](/static/mb/lessons/ornament-chain-4.png)
Using the 4th crocodile clip, connect the end of the crocodile clip onto pin 2 of the micro:bit.
### Step 5
![](/static/mb/lessons/ornament-chain-5.png)
Using the 1st crocodile clip, connect the unattached end of the crocodile clip onto the GND on the 2nd micro:bit.
### Step 6
![](/static/mb/lessons/ornament-chain-6.png)
Using the 2nd crocodile clip, connect the unattached end of the crocodile clip onto the 3V pin on the 2nd micro:bit.
### Step 7
![](/static/mb/lessons/ornament-chain-7.png)
Using the 3rd crocodile clip, connect the unattached end of the crocodile clip onto pin 2 of the 2nd micro:bit.
### Step 8
![](/static/mb/lessons/ornament-chain-8.png)
Using the 4th crocodile clip, connect the unattached end of the crocodile clip onto pin 1 of the 2nd micro:bit
### Step 9
![](/static/mb/lessons/telegraph-0.png)
### ~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!
### ~

View File

@ -0,0 +1,75 @@
# telegraph - making
### ~avatar
Let's build a telegraph between two micro:bits.
### ~
![](/static/mb/lessons/telegraph-0.png)
## Materials
* micro:bit, battery holder and 2 AAA batteries
* Crocodile clips
## Steps
### Step 1
![](/static/mb/lessons/banana-keyboard-1.png)
Using the 1st crocodile clip, connect the end of the crocodile clip onto GND pin on the micro:bit.
### Step 2
![](/static/mb/lessons/ornament-chain-2.png)
Using the 2nd crocodile clip, connect the end of the crocodile clip onto the 3V pin on the micro:bit.
### Step 3
![](/static/mb/lessons/ornament-chain-3.png)
Using the 3rd crocodile clip, connect the end of the crocodile clip onto pin 1 of the micro:bit.
### Step 4
![](/static/mb/lessons/ornament-chain-4.png)
Using the 4th crocodile clip, connect the end of the crocodile clip onto pin 2 of the micro:bit.
### Step 5
![](/static/mb/lessons/ornament-chain-5.png)
Using the 1st crocodile clip, connect the unattached end of the crocodile clip onto the GND on the 2nd micro:bit.
### Step 6
![](/static/mb/lessons/ornament-chain-6.png)
Using the 2nd crocodile clip, connect the unattached end of the crocodile clip onto the 3V pin on the 2nd micro:bit.
### Step 7
![](/static/mb/lessons/ornament-chain-7.png)
Using the 3rd crocodile clip, connect the unattached end of the crocodile clip onto pin 2 of the 2nd micro:bit.
### Step 8
![](/static/mb/lessons/ornament-chain-8.png)
Using the 4th crocodile clip, connect the unattached end of the crocodile clip onto pin 1 of the 2nd micro:bit
### Step 9
![](/static/mb/lessons/telegraph-0.png)
### ~button /projects/telegraph/manual-telegraph
NEXT: manual telegraph
### ~

View File

@ -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:
![](/static/mb/lessons/telegraph-0.png)
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)
}
```
@ -64,27 +58,24 @@ Let's add a forever loop so this code runs in the background forever. Modify you
```blocks
basic.forever(() => {
if (input.buttonIsPressed(Button.A)) {
pins.digitalWritePin(DigitalPin.P0, 1)
led.plot(2, 2)
} else {
pins.digitalWritePin(DigitalPin.P0, 0)
basic.clearScreen()
}
})
pins.digitalWritePin(DigitalPin.P0, 1)
led.plot(2, 2)
} else {
pins.digitalWritePin(DigitalPin.P0, 0)
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
### ~

View 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.
![](/static/mb/projects/timing-gates/sketchgates.jpg "Sketch of the gates")
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``.
![](/static/mb/projects/timing-gates/sketchgate1.jpg "Sketch first gate")
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``.
![](/static/mb/projects/timing-gates/sketchgate2.jpg "Sketch first gate")
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!
![](/static/mb/projects/timing-gates/sketchmath.jpg "Sketch math")
## Materials
* Carboard
* Aluminum fail
* Double-side tape (carpet tape)
* 4 crocodile clips
* A micro:bit board and USB cable
![](/static/mb/projects/timing-gates/materials.jpg "Materials")
## 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.
![](/static/mb/projects/timing-gates/tape.jpg "Double sided tape")
Lay the Aluminum foil on the double-sided tape. Press firmly on the tape to get a good bonding of the foil.
![](/static/mb/projects/timing-gates/stickfoil.jpg "Foil sensor")
Strip the out foil around and between the tape strips. Make sure both foil strips don't touch each other.
![](/static/mb/projects/timing-gates/spreadfoil.jpg "Foil taped")
Connect a crocodile strip to each foil strip.
![](/static/mb/projects/timing-gates/connectsensor.jpg "Connecting sensor")
Connect the crocodile plugs to the ``GND`` and ``P0`` pins on the micro:bit.
![](/static/mb/projects/timing-gates/connectcrocs.jpg "Connecting the micro:bit")
The gate is ready to use! Your circuit should look like the picture below:
![](/static/mb/projects/timing-gates/sensordone.jpg "A single gate")
## 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.
![](/static/mb/projects/timing-gates/carfoil.jpg "Attaching foil to the car")
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.
![](/static/mb/projects/timing-gates/sensor2.jpg "Double foil sensors")
Connect the crocodile plugs to the ``GND`` and ``P1`` pins on the micro:bit.
![](/static/mb/projects/timing-gates/sensormicrobit2.jpg "Sensor and microbit")
## 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!

20
docs/raspberry-pi.md Normal file
View File

@ -0,0 +1,20 @@
# 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
with [Raspbian Jessie with Pixel](https://www.raspberrypi.org/downloads/raspbian/).
## Web editor
Starting with **Raspbian Pixel**, Raspbian comes with Chromium. Simply open [](https://codethemicrobit.com).
## Command line
The PXT command line also works on Raspbian and allows to run a local server and/or edit programs from any text editor.
* Node.JS 6.0 needs installed
To install all the tools,
```
curl -s https://raw.githubusercontent.com/Microsoft/pxt-rpi/master/install.sh | sh -
```

View File

@ -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);

88
docs/share.md Normal file
View File

@ -0,0 +1,88 @@
# Sharing your project
Once you've made your project, you can save it the cloud, share it, or embed it on another website.
* Click **More...**, then **Embed Project**:
![Asks to embed](/static/embed/publish.png)
* Click **Publish project**. This will make the project publicly available
* You will then see this information:
![Embedding information](/static/embed/embed-info.png)
## Sharing the URL
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:
![Project page](/static/embed/project-page.png)
## 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
![Blogger](/static/embed/blogger.png)
### Squarespace
[Squarespace][] allows you to embed HTML code inside a blog post or page. In the editor, click to add a new block:
![Squarespace block insertion](/static/embed/squarespace-insert.png)
Scroll to **More** and select **Code**. Paste the embed HTML and click **Apply**:
![Squarespace code insertion](/static/embed/squarespace-code.png)
### 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/

17
docs/static/Calliopeminieditor.svg vendored Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" width="179.9" height="32.4" viewBox="0 0 179.9 32.4">
<path fill="#495260" d="M33.1 11.2h-8.5V5.8c0-2.3 1.9-4.2 4.2-4.2 2.3 0 4.2 1.9 4.2 4.2v5.4z"/>
<path fill="#7F96A1" d="M25.8 3.6H32v7.6h-6.2z"/>
<path fill="#845B32" d="M12.2 7.2V18h12.5V7.2c0-3.4-2.8-6.2-6.2-6.2s-6.3 2.8-6.3 6.2z"/>
<path fill="#26A7AA" d="M28.9 31.4H8.7c-6.3 0-9-8-4-11.8L16 11.2h17.1v16c0 2.3-1.9 4.2-4.2 4.2z"/>
<path fill="#43C9C9" d="M15.2 17.7l-8.8.7 10.7-8"/>
<path fill="#F6F4E7" d="M14.8 15.1l2.3-4.7 1.5 4.7m0 0l1.4-4.7 2.3 4.7"/>
<path fill="#BDD1CF" d="M21.9 17.7h-6.7l-.4-2.6h7.5"/>
<path fill="#F6F4E7" d="M26.8 31.4c-.6-4.6-1.9-10.2-4.8-13.7h-6.8c-3 3.5-4.2 9.1-4.8 13.7h16.4z"/>
<path fill="#FFCD9A" d="M18.6 10.5c-1.4 0-2.6-1.2-2.6-2.6V5h5.1v2.9c0 1.5-1.1 2.6-2.5 2.6z"/>
<path fill="#BDD1CF" d="M15.4 31.4V17.7c2.2 5.1 4.9 11.3 8.2 13.7h-8.2z"/>
<path fill="#FFCD9A" d="M17.1 10.4l1.5 4.7 1.4-4.7"/>
<path fill="#43C9C9" d="M25.8 11.2h7.3v9.4"/>
<path fill="#BCD1CF" d="M52.3 15.1h-1.6l-.2-1.4c-.2-.2-.5-.4-.8-.5s-.7-.2-1.2-.2c-.9 0-1.7.3-2.2 1s-.8 1.6-.8 2.7v.4c0 1.1.3 2 .8 2.7.5.7 1.2 1 2.1 1 .4 0 .8-.1 1.2-.2.4-.1.6-.3.8-.5l.2-1.4h1.6v2.1c-.4.5-1 .9-1.7 1.2-.7.3-1.4.5-2.3.5-1.5 0-2.6-.5-3.6-1.5s-1.4-2.3-1.4-3.9v-.4c0-1.6.5-2.9 1.4-3.9s2.1-1.5 3.6-1.5c.8 0 1.6.2 2.3.5.7.3 1.2.7 1.7 1.2v2.1zm1.5 5.9l.8-.1 3.3-9.4h2.2l3.3 9.4.8.1v1.3h-3.7V21l.8-.1-.5-1.5h-3.5l-.5 1.5.8.1v1.3h-3.7V21zm3.9-3.2h2.5L59 14l-1.3 3.8zm7.8 4.5V21l1.2-.2V13l-1.2-.2v-1.3H70v1.3l-1.2.2v7.6h3.1l.1-1.4h1.7v3h-8.2zm9.5 0V21l1.2-.2V13l-1.2-.2v-1.3h4.6v1.3l-1.3.2v7.6h3.1l.1-1.4h1.7v3H75zm9.5-9.5v-1.3H89v1.3l-1.1.2v7.8l1.1.2v1.3h-4.5V21l1.2-.2V13l-1.2-.2zm15.9 4.2c0 1.6-.5 2.9-1.4 3.9-.9 1-2.1 1.6-3.6 1.6s-2.6-.5-3.5-1.6-1.4-2.3-1.4-3.9v-.2c0-1.6.4-2.9 1.3-3.9s2.1-1.6 3.5-1.6c1.5 0 2.7.5 3.6 1.6s1.4 2.4 1.4 3.9v.2zm-2.2-.2c0-1.1-.2-2-.7-2.7s-1.2-1-2.1-1-1.6.3-2 1-.7 1.6-.7 2.7v.2c0 1.1.2 2.1.7 2.8.5.7 1.1 1 2 1 .9 0 1.6-.3 2.1-1s.7-1.6.7-2.8v-.2zm8.8-5.3c1.2 0 2.2.3 2.9 1S111 14 111 15s-.4 1.9-1.1 2.5c-.7.6-1.7.9-2.9.9h-1.8v2.4l1.2.2v1.3h-4.5V21l1.2-.2V13l-1.2-.2v-1.3h5.1zm-1.8 5.2h1.8c.6 0 1.1-.2 1.4-.5s.5-.8.5-1.3-.2-1-.5-1.3c-.3-.3-.8-.5-1.4-.5h-1.8v3.6zm14.1.9h-3.7v3.1h3.5l.1-1.3h1.7v3h-8.6V21l1.2-.2V13l-1.2-.2v-1.3h8.6v3h-1.7l-.1-1.3h-3.5v2.7h3.7v1.7z"/>
<path fill="#FFF" d="M134.3 11.6l.1 1.1c.2-.4.5-.7.9-1 .4-.2.8-.4 1.3-.4s.8.1 1.1.3c.3.2.5.5.7.8.2-.3.5-.6.8-.8.3-.2.7-.3 1.2-.3.4 0 .7.1 1 .2.3.1.5.3.8.6.2.3.4.6.5 1 .1.4.2.9.2 1.4v7.8h-2.2v-7.9c0-.4-.1-.7-.3-.9-.2-.2-.4-.2-.7-.2-.3 0-.5.1-.6.2s-.3.3-.3.5v8.3h-2.2v-7.9c0-.4-.1-.7-.3-.9-.2-.2-.4-.3-.7-.3-.3 0-.5.1-.7.2-.2.1-.3.3-.4.5v8.3h-2.2V11.6h2zm11.3 0h5.7v8.8h3.2v2h-8.9v-2h3.3v-6.8h-3.3v-2zm3.1-2.8c0-.4.1-.7.4-.9.2-.2.6-.4 1-.4s.8.1 1 .4c.2.2.4.5.4.9s-.1.7-.4.9c-.2.2-.6.4-1 .4s-.8-.1-1-.4c-.2-.2-.4-.5-.4-.9zm10.7 2.8l.1 1.5c.4-.5.9-1 1.4-1.2.6-.3 1.2-.4 1.8-.4.5 0 1 .1 1.5.2.5.2.8.4 1.2.7.3.3.6.8.8 1.3.2.5.3 1.2.3 1.9v6.7h-2.4v-6.7c0-.4-.1-.8-.2-1.1-.1-.3-.2-.5-.4-.7-.2-.2-.4-.3-.7-.4-.3-.1-.6-.1-.9-.1-.5 0-1 .1-1.4.3-.4.2-.7.5-.9.9v7.7h-2.4V11.6h2.2zm10.6 0h5.7v8.8h3.2v2H170v-2h3.3v-6.8H170v-2zm3.1-2.8c0-.4.1-.7.4-.9.2-.2.6-.4 1-.4s.8.1 1 .4c.2.2.4.5.4.9s-.1.7-.4.9c-.2.2-.6.4-1 .4s-.8-.1-1-.4c-.3-.2-.4-.5-.4-.9z"/>
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

145
docs/static/Logo_Calliope_Woman.svg vendored Normal file
View File

@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Ebene_1"
x="0px"
y="0px"
viewBox="0 0 175.49999 172.4"
enable-background="new 0 0 841.9 595.3"
xml:space="preserve"
inkscape:version="0.91 r13725"
sodipodi:docname="Logo_Calliope_Woman.svg"
width="175.5"
height="172.39999"><metadata
id="metadata5011"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs5009" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1137"
id="namedview5007"
showgrid="false"
inkscape:zoom="0.34208337"
inkscape:cx="420.95001"
inkscape:cy="297.64999"
inkscape:window-x="-8"
inkscape:window-y="156"
inkscape:window-maximized="1"
inkscape:current-layer="Ebene_1" /><g
id="g4955"
transform="translate(-260.90025,-204.1)"><g
id="g4957"><defs
id="defs4959"><rect
id="SVGID_7_"
x="193.10001"
y="204.10001"
width="318.29999"
height="256.29999" /></defs><clipPath
id="SVGID_1_"><use
xlink:href="#SVGID_7_"
overflow="visible"
id="use4963"
style="overflow:visible"
x="0"
y="0"
width="100%"
height="100%" /></clipPath></g><g
id="g4965"><defs
id="defs4967"><rect
id="SVGID_9_"
x="193.10001"
y="204.10001"
width="318.29999"
height="256.29999" /></defs><clipPath
id="SVGID_2_"><use
xlink:href="#SVGID_9_"
overflow="visible"
id="use4971"
style="overflow:visible"
x="0"
y="0"
width="100%"
height="100%" /></clipPath></g><g
id="g4973"><defs
id="defs4975"><rect
id="SVGID_11_"
x="193.10001"
y="204.10001"
width="318.29999"
height="256.29999" /></defs><clipPath
id="SVGID_3_"><use
xlink:href="#SVGID_11_"
overflow="visible"
id="use4979"
style="overflow:visible"
x="0"
y="0"
width="100%"
height="100%" /></clipPath><path
clip-path="url(#SVGID_3_)"
d="m 436.4,262 -47.9,0 0,-46 c 0,-4.7 3.8,-8.4 8.4,-8.4 l 31,0 c 4.7,0 8.4,3.8 8.4,8.4 l 0,46 z"
id="path4981"
inkscape:connector-curvature="0"
style="fill:#4a5261" /></g><rect
x="394.79999"
y="218.7"
width="35.099998"
height="43.200001"
id="rect4983"
style="fill:#8096a1" /><path
d="m 317.6,239.5 0,61 71,0.2 c 0,0 0,-57.3 0,-61 0,-19.5 -16.1,-35.6 -35.6,-35.6 -19.6,0 -35.4,15.8 -35.4,35.4"
id="path4985"
inkscape:connector-curvature="0"
style="fill:#855c33" /><path
d="m 412.4,376.5 -114.2,0 c -35.6,0 -50.9,-45.2 -22.6,-66.8 l 63.8,-47.8 96.9,0 0,90.7 c 0.1,13.2 -10.6,23.9 -23.9,23.9"
id="path4987"
inkscape:connector-curvature="0"
style="fill:#26a6ab" /><polygon
points="345.7,257.3 334.8,298.8 285.1,302.5 "
id="polygon4989"
style="fill:#42c9c9" /><polygon
points="354,283.8 332.5,283.8 345.7,257.3 "
id="polygon4991"
style="fill:#f7f5e8" /><polygon
points="375.4,283.8 354,283.8 362.2,257.3 "
id="polygon4993"
style="fill:#f7f5e8" /><polygon
points="373.1,298.8 334.8,298.8 332.5,283.8 375.4,283.8 "
id="polygon4995"
style="fill:#bdd1cf" /><path
d="m 400.6,376.5 c -3.5,-26.2 -10.6,-58 -27.3,-77.7 l -0.2,0 -19,0 -19,0 -0.2,0 c -16.7,19.8 -23.8,51.5 -27.3,77.7 l 93,0 z"
id="path4997"
inkscape:connector-curvature="0"
style="fill:#f7f5e8" /><path
d="m 357,258 -6.1,0 c -6.4,0 -11.5,-5.2 -11.5,-11.5 l 0,-19.7 29.2,0 0,19.7 c -0.1,6.3 -5.3,11.5 -11.6,11.5"
id="path4999"
inkscape:connector-curvature="0"
style="fill:#ffcc99" /><path
d="m 335.8,376.5 0,-77.7 c 12.4,29.1 27.7,64.3 46.5,77.7 l -46.5,0 z"
id="path5001"
inkscape:connector-curvature="0"
style="fill:#bdd1cf" /><polygon
points="362.2,257.3 345.7,257.3 354,283.8 "
id="polygon5003"
style="fill:#ffcc99" /><polygon
points="436.4,315.3 394.8,262 436.4,262 "
id="polygon5005"
style="fill:#42c9c9" /></g></svg>

After

Width:  |  Height:  |  Size: 5.2 KiB

Some files were not shown because too many files have changed in this diff Show More