Compare commits

..

102 Commits

Author SHA1 Message Date
8ba27ccc2d 0.2.166 2016-06-15 23:18:13 -07:00
ff646d32b5 Bump pxt-core to 0.2.179 2016-06-15 23:18:09 -07:00
75d99b324c Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-06-15 23:14:30 -07:00
ece91d980a updated bundled translations 2016-06-15 23:12:44 -07:00
a6a9f25e86 updated docs and strings 2016-06-15 22:50:23 -07:00
cc5330bf3d removed broken cross link 2016-06-15 22:22:10 -07:00
4a9e1466e6 Added Parameters section. 2016-06-15 17:56:41 -07:00
fa947036f0 Rewrote in simple language, added xrefs, etc. 2016-06-15 17:01:18 -07:00
0b0884a7eb 0.2.165 2016-06-15 16:54:16 -07:00
d5b2a21d16 Bump pxt-core to 0.2.178 2016-06-15 16:54:14 -07:00
fe28dd9b92 0.2.164 2016-06-15 16:15:51 -07:00
cfcbe8fb41 Bump pxt-core to 0.2.177 2016-06-15 16:15:48 -07:00
d86f820a57 Rewrote in simple language. Replaced screenshot. Added xrefs. 2016-06-15 15:58:35 -07:00
ace1ddb00b 0.2.163 2016-06-15 15:35:15 -07:00
96be411ba2 Bump pxt-core to 0.2.176 2016-06-15 15:35:14 -07:00
f24f7c2279 Rewrote in simple language. Streamlined. Added example. 2016-06-15 14:56:58 -07:00
0130a7753e Rewrote in simple language. Streamlined. Added cross-refs. 2016-06-15 14:14:15 -07:00
54b72ba312 reduce to 5 menu items 2016-06-15 14:04:06 -04:00
7bced60466 fix more broken links 2016-06-15 08:09:40 -04:00
041b10ef04 fix broken links 2016-06-15 07:55:19 -04:00
0e08b58f84 add basic typescript page 2016-06-15 06:31:18 -04:00
dd14489f47 0.2.162 2016-06-14 21:06:14 -07:00
6d6c2b5e99 Bump pxt-core to 0.2.173 2016-06-14 21:06:13 -07:00
251f382e8e remove old stuff 2016-06-14 22:06:55 -04:00
887a652a06 more remapping 2016-06-14 21:44:51 -04:00
bbbb1ea6bc moving stuff around 2016-06-14 21:37:55 -04:00
2c399f198a move LED namespace after music 2016-06-14 19:16:08 -04:00
54213cf554 put lessons back for Michael 2016-06-14 17:28:08 -04:00
0c67cd8e8b Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-06-14 17:21:02 -04:00
a0a23a261c restructuring to separate language from API 2016-06-14 17:20:45 -04:00
20c7a16524 Used Dimension.X in sample instead of string 2016-06-14 14:01:00 -07:00
0a722b2196 0.2.161 2016-06-14 13:57:46 -07:00
4a537b1ce8 updated bluetooth library 2016-06-14 13:57:27 -07:00
cf0372aeaa adding bluetooth button service. fix for #106 2016-06-14 13:53:05 -07:00
918d2f1a3a support for bluetooth accelerometer service. fix for #105 2016-06-14 13:47:18 -07:00
c1a6c1c66a support for magnetometer service. fix for #112 2016-06-14 13:39:24 -07:00
7a2c4f0056 updated shims 2016-06-14 13:27:21 -07:00
23eefb28d2 support for starting the temperature service #113 2016-06-14 13:24:55 -07:00
2ab2535966 Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-06-14 13:18:43 -07:00
bb20c1780b Add Bluetooth LED service. fix for #111 2016-06-14 13:17:20 -07:00
764505d2ca Rewrite in simple language. Improve code examples. 2016-06-14 12:51:21 -07:00
62b6b8e9eb Second pass. Clarify API's functionality. 2016-06-14 12:12:26 -07:00
beac252620 renaming... 2016-06-14 14:39:31 -04:00
6e62acb384 fixed typo 2016-06-14 12:17:54 -04:00
b5afe25387 avatar for flashing heart 2016-06-14 12:11:29 -04:00
ebea6b29f3 added device section 2016-06-14 11:58:01 -04:00
f4eca66648 move lessons out of web site
will move select lessons back to "educators" section
2016-06-14 11:49:58 -04:00
a6e6dd8287 10 projects, first draft complete 2016-06-14 11:30:25 -04:00
d94c7e0157 lessons to projects 2016-06-14 11:12:13 -04:00
4657263abb minor mods 2016-06-14 10:55:13 -04:00
a6c2b24e8d minor change 2016-06-14 10:31:21 -04:00
31651f9a11 more work on LED screen doc 2016-06-14 10:31:21 -04:00
43c7692a8f 0.2.160 2016-06-14 06:40:57 -07:00
7f05de734c Bump pxt-core to 0.2.171 2016-06-14 06:40:55 -07:00
fe39eec686 fixing color, help of io pin service 2016-06-14 06:40:44 -07:00
655fa0fde8 updated annotations 2016-06-14 06:33:18 -07:00
2841df6950 added 'microbit-bluetooth' package 2016-06-14 06:30:07 -07:00
713dfec949 pass over LED screen 2016-06-13 21:43:01 -04:00
23c4087830 Rewrote in simple language. 2016-06-13 15:47:08 -07:00
de293be4fc Rewrote (2nd pass). Changed to . 2016-06-13 14:15:39 -07:00
4e54649ce7 Rewrote in simpler language 2016-06-13 13:39:05 -07:00
caeef2f1e1 Rewrote in simple language 2016-06-13 12:57:42 -07:00
f3d7693a26 typos 2016-06-13 14:53:08 -04:00
2ceece6cdf typos 2016-06-13 14:49:07 -04:00
c2913aea82 fix typos 2016-06-13 14:41:08 -04:00
bf90e01e7e 0.2.159 2016-06-12 06:26:57 -07:00
bbee53607b updated square image 2016-06-12 06:26:45 -07:00
e94e2e7dc4 remove references to language primitives 2016-06-12 08:16:04 -04:00
02a0839a4e typos 2016-06-11 22:37:09 -04:00
67ea6c01f2 remove linksto lessons from references 2016-06-11 22:28:57 -04:00
5b5cac878b starting to reorganize lessons 2016-06-11 22:15:36 -04:00
56301d2d6f linking in maker activities 2016-06-11 21:12:08 -04:00
f8e80e6a9d pics for music 2016-06-11 20:54:12 -04:00
d1f314d790 added compass 2016-06-11 19:43:54 -04:00
27f39b4458 move rock paper scissors to correct position 2016-06-11 18:08:05 -04:00
0c40f79dec three projects down 2016-06-11 17:12:12 -04:00
346ec3d1a6 finish second lesson 2016-06-11 14:40:09 -04:00
5a2896808e fix up pics 2016-06-10 23:39:30 -04:00
4a34edeab0 get it in the menu 2016-06-10 23:15:12 -04:00
5c2833978b name change 2016-06-10 23:10:32 -04:00
edfc2274a2 change name 2016-06-10 23:10:00 -04:00
899c9fd8d6 finish first lesson 2016-06-10 23:09:18 -04:00
13f63c2f46 Rewrote in simple language. Purged legacy example. 2016-06-10 16:13:37 -07:00
8841c47638 Rewrote in simple language. Fixed some typos. 2016-06-10 14:44:49 -07:00
c6f5a8dcc6 updated help links. fix for #90 2016-06-09 21:41:41 -07:00
786c5f9733 0.2.158 2016-06-09 21:14:54 -07:00
0cdedd02b4 updated rendering of buttons 2016-06-09 21:14:33 -07:00
aba028b1e8 Rewrote in simple language. Updated code example. 2016-06-09 18:25:59 -07:00
3049c88d5b Simulator warnings, etc. 2016-06-09 15:30:47 -07:00
8239329c2e Rewrote with simple language 2016-06-09 15:09:48 -07:00
c9d4807f25 0.2.157 2016-06-09 14:08:27 -07:00
5f4ff08c09 Bump pxt-core to 0.2.170 2016-06-09 14:08:25 -07:00
b99be68ea5 display bolts on simulator button 2016-06-09 14:08:15 -07:00
c639cc3f83 Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-06-09 13:05:21 -07:00
cd56181703 Rewrote in simple language. API might not be functional. 2016-06-09 12:34:56 -07:00
5b1a807443 updated windows 10 app manifest 2016-06-09 11:49:40 -07:00
e604b27c4f various docs updates 2016-06-09 11:10:01 -07:00
4727b105c4 Rewrote in simple language. May be an obsolete API. 2016-06-08 18:14:00 -07:00
4063b5aac8 Rewrote in simple language. Deleted redundant material. 2016-06-08 16:59:20 -07:00
ee8505b4f1 0.2.156 2016-06-08 14:52:16 -07:00
ab4e2c458a Bump pxt-core to 0.2.168 2016-06-08 14:52:15 -07:00
126c236b14 New topic. Double-checked example. 2016-06-08 11:21:58 -07:00
161 changed files with 2005 additions and 1355 deletions

View File

@ -29,24 +29,29 @@ The BBC micro:bit was made possible by many [partners](https://www.microbit.co.u
The micro:bit provides an easy and fun introduction to programming and making switch on, program it to do something fun wear it, customize it.
Just like Arduino, the micro:bit can be connected to and interact with sensors, displays, and other devices.
## Blocks or JavaScript
## Hardware: The Device
The student can program the BBC micro:bit using [visual blocks](http://www.github.com/Google/blockly) or JavaScript.
Learn about about the [hardware components](/device) of the micro:bit to make the most of it!
## Programming: Blocks or JavaScript
The student can program the BBC micro:bit using [Blocks](/blocks) or [JavaScript](/typescript), via the [micro:bit APIs](/reference):
```blocks
basic.showString("BBC micro:bit!");
basic.showString("Hi!");
```
## Compile and Flash
## Compile and Flash: Your Program!
When a user has her code ready, she can connect her BBC micro:bit to a computer via a USB cable, so it appears as a mounted drive.
When a user has her code ready, she can connect her BBC micro:bit to a computer via a USB cable, so it appears as a mounted drive (named MICROBIT).
Compilation to the ARM thumb machine code happens in the browser.
Compilation to ARM thumb machine code from [Blocks](/blocks) or [JavaScript](/typescript) happens in the browser.
The student is prompted to save the ARM binary program to a file, which she then simply drags to the micro:bit mounted drive,
which flashes the micro:bit device with the new program.
## Simulator: Test Your Code
Before a student compiles her code for the micro:bit, she can run it 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.
@ -54,5 +59,10 @@ The simulator has support for the LED screen, buttons, as well as compass, accel
The [C++ BBC 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,
as well as a set of helper functions (such as displaying a number/image/string on the LED screen).
The JavaScript micro:bit library mirrors the functions of the C++ library.
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
The editor for the BBC micro:bit is [open source](/open-source) on GitHub. Contributors are welcome!

8
docs/blocks.md Normal file
View File

@ -0,0 +1,8 @@
# Blocks language
```namespaces
for (let i = 0;i<5;++i) {}
if (true){}
let x = 0;
Math.random(5);
```

View File

@ -2,8 +2,6 @@
true or false.
### @parent blocks/language
A Boolean has one of two possible values: `true`; `false`. Boolean (logical) operators (*and*, *or*, *not*) take Boolean inputs and yields a Boolean value. Comparison operators on other types ([numbers](/reference/types/number), [strings](/reference/types/string) yields a Boolean value.
The following blocks represent the true and false Boolean values, which can be plugged in anywhere a Boolean value is expected:
@ -32,7 +30,7 @@ The next six blocks represent comparison operators that yield a Boolean value. M
42 >= 0;
```
Boolean values and operators are often used with an [if](/reference/logic/if) or [while](/reference/loops/while) statement to determine which code will execute next. For example:
Boolean values and operators are often used with an [if](/blocks/logic/if) or [while](/blocks/loops/while) statement to determine which code will execute next. For example:
### Functions that return a Boolean
@ -98,11 +96,7 @@ if(x < 5) {
See the documentation on [Numbers](/reference/types/number) for more information on comparing two Numbers. You can also [compare strings](/reference/types/string-functions) using the `equals` function.
### Lessons
[rotation animation](/lessons/rotation-animation), [love meter](/lessons/love-meter), [zoomer](/lessons/zoomer)
### See also
[if](/reference/logic/if), [while](/reference/loops/while), [number](/reference/types/number)
[if](/blocks/logic/if), [while](/blocks/loops/while), [number](/reference/types/number)

28
docs/blocks/logic/if.md Normal file
View File

@ -0,0 +1,28 @@
# If
### @parent blocks/language
Conditionally run code depending on whether a [Boolean](/blocks/logic/boolean) condition is true or false.
```blocks
if(true) {
}
```
Click on the dark blue gear icon (see above) to add an *else* or *if* to the current block.
### Example: adjusting screen brightness
```blocks
if(input.lightLevel()<100){
led.setBrightness(255);
}
```
If the [light level](/reference/input/light-level) is `< 100`, this code sets the brightness to `255`:
### See also
[while loop](/blocks/loops/while), [for](/blocks/loops/for), [boolean](/blocks/logic/boolean)

View File

@ -2,7 +2,6 @@
```cards
for(let i = 0;i<5;i++) {}
for(let i = 1;i<5;i++) {}
while(true) {}
basic.forever(() => {})
basic.forever(() => {});
```

View File

@ -14,11 +14,7 @@ basic.showNumber(i)
}
```
### Lessons
[looper](/lessons/looper)
### See also
[repeat](/reference/loops/repeat), [while](/reference/loops/while), [if](/reference/logic/if), [show number](/reference/basic/show-number)
[repeat](/blocks/loops/repeat), [while](/blocks/loops/while), [if](/blocks/logic/if), [show number](/reference/basic/show-number)

View File

@ -0,0 +1,12 @@
# Repeat
Run part of the program the number of times you say.
### Block Editor
![](/static/mb/blocks/contents-0.png)
### See also
[for](/blocks/loops/for), [while](/blocks/loops/while), [if](/blocks/logic/if), [show number](/reference/basic/show-number)

View File

@ -1,16 +1,13 @@
# While
### @parent blocks/language
Repeat code while a [Boolean](/reference/types/boolean) `condition` is true.
Repeat code while a [Boolean](/blocks/logic/boolean) `condition` is true.
```blocks
while(true) {
}
```
The while loop has a *condition* that evaluates to a [Boolean](/reference/types/boolean) value. After the `do` keyword, add the code that you want to run while the `condition` is `true`. The while loop concludes with `end while`.
The while loop has a *condition* that evaluates to a [Boolean](/blocks/logic/boolean) value. After the `do` keyword, add the code that you want to run while the `condition` is `true`. The while loop concludes with `end while`.
The condition is tested before any code runs. Which means that if the condition is false, the code inside the loop doesn't execute.
@ -26,11 +23,7 @@ while(index >= 0) {
}
```
### Lessons
[rotation animation](/lessons/rotation-animation)
### See also
[on button pressed](/reference/input/on-button-pressed), [for](/reference/loops/for), [if](/reference/logic/if), [forever](/reference/basic/forever)
[on button pressed](/reference/input/on-button-pressed), [for](/blocks/loops/for), [if](/blocks/logic/if), [forever](/reference/basic/forever)

View File

@ -1,15 +1,9 @@
# Math Library
Functions in the math library.
# Math functions
### @parent blocks/language
The math library includes math related functions that you can use with [Numbers](/reference/types/number).
* In the [Block editor](/blocks/editor), click **maths** on the left to see the available blocks
The functions available in Block Editor are:
### abs
math `->` abs (x : [Number](/reference/types/number)) *returns* [Number](/reference/types/number)
@ -42,11 +36,7 @@ returns a random [Number](/reference/types/number) between 0 and the parameter *
![](/static/mb/blocks/math-3.png)
### Lessons
[love meter](/lessons/love-meter)
### See also
[Block Editor documentation](/blocks/contents), [Number](/reference/types/number)
[Number](/reference/types/number)

View File

@ -1,6 +1,6 @@
## Variables
[Assign](/reference/variables/assign) (set) a variable's value
[Assign](/blocks/variables/assign) (set) a variable's value
```blocks
let x = 0;
@ -13,7 +13,7 @@ let x = 0;
x;
```
[Change](/reference/variables/change-var) a variable's value
[Change](/blocks/variables/change-var) a variable's value
```blocks
let x = 0;

View File

@ -1,6 +1,6 @@
# Assignment Operator
Use an equals sign to make a [variable](/reference/variables/var) store the [number](/reference/types/number)
Use an equals sign to make a [variable](/blocks/variables/var) store the [number](/reference/types/number)
or [string](/reference/types/string) you say.
When you use the equals sign to store something in a variable, the equals sign is called
@ -30,11 +30,7 @@ You can use the assignment operator with variables of
every [type](/reference/types). A *type* is which kind of thing
a variable can store, like a number or string.
### Lessons
[rotation animation](/lessons/rotation-animation)
### See also
[variable](/reference/variables/var), [types](/reference/types)
[variable](/blocks/variables/var), [types](/reference/types)

View File

@ -0,0 +1,40 @@
# Change Value
Set the value for local and global variables.
### @parent blocks/change-value
Change the value of a variable
```blocks
let x = 0
x += 1
```
### Declare a variable
Use the assignment operator to set the value of a [variable](/blocks/variables/var). Change the value of a variable from 0 to 1 using the change item block. Like this:
```blocks
let x = 0
x += 1
```
### Example
Use the assignment operator to set the value of a [variable](/blocks/variables/var). Change the value of a variable from 0 to 1 using the change item block. Then display the new value of the variable on the LED screen. Like this:
```blocks
let x = 0;
x += 1;
basic.showNumber(x);
```
### Notes
* You can use the assignment operator with variables of each of the supported [types](/reference/types).
### See also
[variable](/blocks/variables/var), [types](/reference/types)

View File

@ -13,7 +13,7 @@ A variable is a place where you can store and retrieve data. Variables have a na
### Var statement
Use the Block Editor variable statement to create a variable
and the [assignment operator](/reference/variables/assign)
and the [assignment operator](/blocks/variables/assign)
to store something in the variable.
For example, this code stores the number `2` in the `x` variable:
@ -27,7 +27,7 @@ Here's how to define a variable in the Block Editor:
2. Change the default variable name if you like.
3. Drag a block type on the right-side of the [assignment operator](/reference/variables/assign) and click the down arrow to change the variable name.
3. Drag a block type on the right-side of the [assignment operator](/blocks/variables/assign) and click the down arrow to change the variable name.
A variable is created for the number returned by the [brightness](/reference/led/brightness) function.
@ -81,11 +81,7 @@ if (led.brightness() > 128) {
* You can use the default variable names if you'd like, however, it's best to use descriptive variable names. To change a variable name in the editor, select the down arrow next to the variable and then click "new variable".
### Lessons
[glowing pendulum](/lessons/glowing-pendulum), [love meter](/lessons/love-meter), [temperature](/lessons/temperature), [zoomer](/lessons/zoomer)
### See also
[types](/reference/types), [assignment operator](/reference/variables/assign)
[types](/reference/types), [assignment operator](/blocks/variables/assign)

View File

@ -15,12 +15,14 @@ It flashes yellow when the system wants to tell the user that something has happ
### Buttons
Buttons A and B are a form of input. When you press a button, it completes an electrical circuit.
The micro:bit can detect either of its two buttons being pressed and un-pressed and be programmed
to act on that or send the information to another device.
The micro:bit can detect either of its two buttons being pressed/released and be programmed
to act on these events.
Button R on the back of the micro:bit is a system button. It has different uses.
When you have downloaded and run your code onto your micro:bit, press Button R to restart and run your program from the beginning.
### USB connection
When you plug in your micro:bit, it should appear as MICROBIT.
If you accidentally hold down the reset button as youre plugging in your micro:bit,
the micro:bit will appear as a MAINTENANCE drive instead of MICROBIT. This is known as maintenance mode.**
@ -43,7 +45,7 @@ This data can be used by the micro:bit in a program or be sent to another device
### Accelerometer
There is a an accelerometer on your micro:bit which detects changes in the micro:bits speed.
There is an accelerometer on your micro:bit which detects changes in the micro:bits speed.
It converts analogue information into digital form that can be used in micro:bit programs.
Output is in milli-g. The device will also detect a small number of standard actions e.g. shake, tilt and free-fall.
@ -63,7 +65,7 @@ and about the error messages you might get [here](/device/error-codes).
### Powering your micro:bit
When your micro:bit is connected to your computer with the micro USB, it doesnt need another power source.
When your micro:bit is connected to your computer with the micro USB, it doesnt need another power source.
When your micro:bit isnt connected to your computer, tablet or mobile, you will need 2 x AAA 1.5 V batteries to power it.
The pins labelled 3V and GND are the power supply pins.
@ -75,7 +77,7 @@ The BBC micro:bit can send an receive data via [serial communication](/device/se
### Bluetooth Low Energy (BLE) Antenna
You will see the label BLE ANNTENA on the back of your micro:bit. It is for a messaging service,
You will see the label BLE ANTENNA on the back of your micro:bit. It is for a messaging service,
so that devices can talk to each other. The micro:bit is a peripheral
device which can talk to a central device like a smart phone or tablet that has Bluetooth Low Energy (BLE).
The micro:bit can send signals and receive signals from a central device so another BLE device can

View File

@ -1,7 +1,5 @@
# micro:bit - the device
The micro:bit device
The micro:bit is a very capable device with many components:
* [the USB connector](/device/usb)

View File

@ -11,12 +11,6 @@ This example displays a random number every time the crocodile clip holds `GND`
### Connecting Crocodile Clips
### Lessons
[love meter](/lessons/love-meter)
### 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)

View File

@ -1,7 +1,5 @@
# The micro:bit - a reactive system
The micro:bit is a reactive system.
### Computing systems
What sort of a *computing system* is the micro:bit?

View File

@ -3,40 +3,61 @@
The micro:bit LED screen
```sim
basic.showString(" ");
basic.showLeds(`
# . # . #
. # . # .
# . # . #
. # . # .
# . # . #
`);
```
The micro:bit LED screen consists of 25 red LED lights arranged in a 5X5 grid (5 LEDs across by 5 LEDs down).
In the screen above, we created a checkerboard pattern using the LEDs.
### Which LED?
You use ``x , y`` coordinates to specify a particular LED in the grid; where ``x`` is the horizontal position and ``y`` is the vertical position (0, 1, 2, 3, 4). To figure out the ``x``, ``y`` coordinates, position your micro:bit horizontally, like a credit card (see picture above).
You use `(x ,y)` coordinates to specify a particular LED in the grid;
where `x` is the horizontal position (0,1,2,3,4) and `y` is the vertical position
(0, 1, 2, 3, 4).
To figure out the ``x``, ``y`` coordinates, position your micro:bit horizontally, like a credit card (see picture above).
Here are the x, y coordinates for the LEDs in the 5X5 grid:
`0, 0` `1, 0` `2, 0` `3, 0` `4, 0`
`(0,0)` `(1,0)` `(2,0)` `(3,0)` `(4,0)`
`0, 1` `1, 1` `2, 1` `3, 1` `4, 1`
`(0,1)` `(1,1)` `(2,1)` `(3,1)` `(4,1)`
`0, 2` `1, 2` `2, 2` `3, 2` `4, 2`
`(0,2)` `(1,2)` `(2,2)` `(3,2)` `(4,2)`
`0, 3` `1, 3` `2, 3` `3, 3` `4, 3`
`(0,3)` `(1,3)` `(2,3)` `(3,3)` `(4,3)`
`0, 4` `1, 4` `2, 4` `3, 4` `4, 4`
`(0,4)` `(1,4)` `(2,4)` `(3,4)` `(4,4)`
The x, y coordinates for the LED in the centre of the grid are `2, 2`. Starting from `0, 0` count over 2 columns and then down 2 rows.
The x, y coordinates for the LED in the centre of the grid are `(2,2)`. Starting from `(0,0)` count over 2 columns and then down 2 rows.
### Check your understanding
Which LEDs are turned on in the checkboard pattern above?
### Row, column - 1
Since the row and column numbers start at 0, an easy way to figure out the x, y coordinates is to subtract 1 from the row and column number (when counting from 1). In other words, to specify the LED in the 4th column 5th row, subtract 1 from each number to get coordinates `3, 4`.
Since the row and column numbers start at 0, an easy way to figure out the (x,y) coordinates
is to subtract 1 from the row and column number (when counting from 1).
In other words, to specify the LED in the 4th column 5th row, subtract 1 from each number to get coordinates `(3,4)`.
### Turn a LED on/off
Use [plot](/reference/led/plot) and [unplot](/reference/led/unplot) to turn a LED on or off
```blocks
led.plot(0,0)
led.unplot(0,0)
led.plot(0,0);
led.plot(1,1);
basic.pause(1000);
led.unplot(0,0);
basic.pause(1000);
led.unplot(1,1);
```
### Is a LED on/off?

View File

@ -11,16 +11,35 @@ input.onButtonPressed(Button.A, () => {
})
```
Data is also automatically streamed to serial by the ** bar graph** block
and picked up by the editor. This data can be streamed to the cloud as well.
```blocks
basic.forever(() => {
led.plotBarGraph(input.acceleration(Dimension.X), 0);
});
```
## How to read the micro:bit's serial output from your computer
Unfortunately, using the serial library requires quite a bit of a setup.
### BBC micro:bit Chrome Extension
If you are using the Google Chrome browser, you can use our extension to get serial data streaming in the editor.
* Install the [Extension for BBC micro:bit](https://chrome.google.com/webstore/detail/extension-for-bbc-microbi/cihhkhnngbjlhahcfmhekmbnnjcjdbge?hl=en-US) on the Chrome Web Store.
* Restart Chrome and open the web editor.
### Windows
You must install a device driver (for the computer to recognize the serial interface of the micro:bit); then, you must also install a terminal emulator (which is going to connect to the micro:bit and read its output). Here's how to do it:
* Follow instructions at https://developer.mbed.org/handbook/Windows-serial-configuration in order to install the device driver
* Install a terminal emulator; we recommend [Tera Term](https://ttssh2.osdn.jp/index.html.en). At the time of this writing, the latest version is 4.88 and can be downloaded [from here](http://en.osdn.jp/frs/redir.php?m=jaist&f=%2Fttssh2%2F63767%2Fteraterm-4.88.exe). Follow the instructions from the installer.
#### Windows > Tera Term
* Install the terminal emulator [Tera Term](https://ttssh2.osdn.jp/index.html.en). At the time of this writing, the latest version is 4.88 and can be downloaded [from here](http://en.osdn.jp/frs/redir.php?m=jaist&f=%2Fttssh2%2F63767%2Fteraterm-4.88.exe). Follow the instructions from the installer.
Once both the driver and the terminal emulator are installed, plug in the micro:bit and wait until the device is fully setup. Then, open TeraTerm.
@ -32,7 +51,7 @@ You should be good. Feel free to hit `Setup` > `Save Setup` in the menus to eras
Please note that Windows will assign you a different COM port if you plug in another micro:bit. If you're juggling between micro:bits, you'll have to change the COM port every time.
### Alternative Windows setup with Putty
#### Windows > Putty
If you prefer another terminal emulator (such as [PuTTY](http://www.putty.org/)), here are some instructions.

View File

@ -2,7 +2,8 @@
How to compile, transfer, and run a script on your micro:bit.
While you're writing and testing your Block Editor or Touch Develop scripts, you'll mostly be running scripts in your browser by clicking the `Run` button (see [run code in your browser](/device/simulator) for info about this).
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).
Once your masterpiece is complete, you can compile your script and run it on your micro:bit.

View File

@ -24,10 +24,10 @@ input.onButtonPressed(Button.B, () => {
});
```
* **[getting started](/getting-started)**
* Browse the [API reference](/reference)
* Learn more about the [device](/device)
* Get started with [lessons](/lessons)
* **[getting started](/getting-started)**
* Get started with [projects](/projects)
* Browse the [micro:bit APIs](/reference)
* Learn more about the [micro:bit device](/device)
* Frequently Asked Question [faq](/faq)
* Follow up with the [release notes](/release-notes)

View File

@ -4,7 +4,7 @@
Are you ready to build cool BBC micro:bit programs?
Here are some challenges for you. Unscramble the blocks in the editor
Here are some challenges for you. Arrange the blocks in the editor
to make real programs that work!
## ~
@ -12,7 +12,7 @@ to make real programs that work!
### Happy face
There are three blocks in the editor (the area to the left).
They should look like this:
Arrange them to look like this:
```blocks
basic.forever(() => {

View File

@ -1,6 +1,5 @@
# Lessons
### @short Lessons
### ~column
@ -31,7 +30,6 @@
* [Guess the Number](/lessons/guess-the-number), guess a random number with pick number
* [Counter](/lessons/counter), display a number with a variable
* [Love Meter](/lessons/love-meter), create a love meter with on pin pressed
* [Rock Paper Scissors](/lessons/rock-paper-scissors), create the classic game of rock paper scissors with if statement
* [Truth or Dare](/lessons/truth-or-dare), a game that forces each player to reveal a secret or do something funny with if statement
* [Spinner](/lessons/spinner), spin the arrow with multiple if statements
* [Dice Roll](/lessons/dice-roll), spin with more if statements
@ -44,17 +42,12 @@
* [Zoomer](/lessons/zoomer), measure the force with acceleration
* [Glowing Pendulum](/lessons/glowing-pendulum), construct a pendulum that glows using acceleration
* [Classic Beatbox](/lessons/classic-beatbox), make a beatbox music player with variables
* [Light Beatbox](/lessons/light-beatbox), make a beatbox music player with light level
### ~
### ~column
## Maker
* [The Watch](/lessons/the-watch), design and create The Watch
* [Hack your Headphones](/lessons/hack-your-headphones), create music on the BBC micro:bit by hacking your headphones
* [Banana Keyboard](/lessons/banana-keyboard), create music with fruits
* [Telegraph](/lessons/telegraph), play the telegraph game between two BBC micro:bits
* [Pogo](/lessons/pogo), create a pogo game to test your jumping abilities
## Science
@ -70,5 +63,3 @@
### ~
### @section full
The lessons promote computational thinking and computer science literacy.

View File

@ -1,21 +0,0 @@
# banana keyboard blocks lesson
display beautiful images on the BBC micro:bit.
## Topic
Music
## Quick Links
* [activity](/lessons/banana-keyboard/activity)
## 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). The connect fruit using pins P1 and GND.
## Objectives
* learn how to setup the BBC micro:bit with earphones to play music
* learn how to setup the BBC micro:bit with fruit be the musical instrument

View File

@ -34,7 +34,7 @@ basic.showLeds(`
`)
```
* **variable**: [read more...](/reference/variables/var)
* **variable**: [read more...](/blocks/variables)
* **arithmetic operators**: [read more...](/reference/types/number)
* **on button pressed** : [read more...](/reference/input/on-button-pressed)
* **show number** : [read more...](/reference/basic/show-number)

View File

@ -1,20 +0,0 @@
# hack your headphones lesson
display beautiful images on the BBC micro:bit.
## Topic
Hack your headphone
## Quick Links
* [activity](/lessons/hack-your-headphones/activity)
## 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, headphones (or speakers), as well as crocodile clips (or spring clips).
## Objectives
* learn how to setup the BBC micro:bit with headphones to play music

View File

@ -42,19 +42,18 @@ Learn how to create a charades game with **collections**, ` create -> Collection
## Documentation
* **collection**
* **global variables** : [read more...](/reference/variables/globals.md)
* **Boolean** : [read more...](/reference/types/boolean)
* **on logo up** [read more...](/functions/on-logo-up)
* **on screen down** [read more...](/functions/on-screen-down)
* **on screen up** [read more...](/functions/on-screen-up)
* **variables** : [read more...](/blocks/variables)
* **Boolean** : [read more...](/blocks/logic/boolean)
* **on logo up** [read more...](/reference/input/on-gesture)
* **on screen down** [read more...](/reference/input/on-gesture)
* **on screen up** [read more...](/reference/input/on-gesture)
* **show string** : [read more...](/reference/basic/show-string)
* **game library** : [read more...](/reference/game-library)
* **game library** : [read more...](/reference/game)
## Resources
* Activity: [tutorial](/lessons/headbands/activity)
* Activity: [quiz](/lessons/headbands/quiz)
* Extended Activity: [challenges](/lessons/headbands/challenges)
* Quiz: [quiz](/lessons/headbands/quiz)
## Objectives
@ -115,15 +114,6 @@ Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algor
* [tutorial](/lessons/headbands/activity)
* [quiz](/lessons/headbands/quiz)
## Extended Activity
* time: 20 min.
* [challenges](/lessons/headbands/challenges)
## Homework
* Extended Activity: [challenges](/lessons/headbands/challenges)
## Intended follow on
Publish script to the classroom.

View File

@ -1,21 +0,0 @@
# light beatbox
display beautiful images on the BBC micro:bit.
## Topic
Music
## Quick Links
* [activity](/lessons/light-beatbox/activity)
## Prior learning/place of lesson in scheme of work
Learn how to make a light beatbox music player using the light sensor. We will be learning how to code musical notes using light level, a local variable, conditionals, on button pressed as well as simple commands such as ring tone and rest.
## Objectives
* learn how to control the light sensor on the BBC micro:bit
* learn how to code music on the BBC micro:bit

View File

@ -1,62 +0,0 @@
# rock paper scissors lesson
A game against the BBC micro:bit.
## Topic
Local Variables
## Quick Links
* [activity](/lessons/rock-paper-scissors/activity)
* [challenges](/lessons/rock-paper-scissors/challenges)
## Class
Year 7
## Prior learning/place of lesson in scheme of work
Learn how to create a **local variable**, `var t :=time` where you can store data, so that you can use it in your code. We will be learning how to create a classic rock paper scissors game using global variables, input on shake, local variables, math random as well as simple commands such as create image, show image, show string, and show number.
## Documentation
```cards
input.onGesture(Gesture.Shake, () => {})
Math.random(3)
let x = 0
basic.showLeds(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . .
`)
```
## Objectives
* learn how to create a condition so the micro:bit will run code when it is shaken
* learn how to create a local variable for a place where you can store data
* learn how to create an image to show on the micro:bit's LED screen
* learn how to show an image on the micro:bit's LED screen
## Progression Pathways / Computational Thinking Framework
#### Algorithms
* Uses diagrams to express solutions.(AB)
* Represents solutions using a structured notation (AL) (AB)
#### Programming & Development
* Creates programs that implement algorithms to achieve given goals (AL)
* Declares and assigns variables(AB)
* Selects the appropriate data types(AL) (AB
#### Data & Data Representation
* Defines data types: real numbers and Boolean (AB)
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation

View File

@ -1,121 +0,0 @@
# rock paper scissors activity
A classic game against the micro:bit.
### ~avatar avatar
Welcome! This tutorial will help you create a game of rock paper scissors with the micro:bit. Let's get started!
### ~
We want the micro:bit to choose rock, paper, or scissors when it is shaken. Let's begin by creating an on shake condition so the micro:bit will run code when it is shaken.
```blocks
input.onGesture(Gesture.Shake, () => {
})
```
Next, create a variable and store pick random number from 0 to 2. On shake, a number will be randomly picked from 0-2. We will randomly display an image based on the random number returned.
```blocks
input.onGesture(Gesture.Shake, () => {
let img = Math.random(3)
})
```
The micro:bit will look like it's showing 1 frame of the image by displaying the whole image when pick random is equal to 2. We can help the micro:bit randomly decide which image to use by pick random. The micro:bit will randomly pick the image to display with show LEDs and the pick random function.
```blocks
input.onGesture(Gesture.Shake, () => {
let img = Math.random(3)
if (img == 2) {
basic.showLeds(`
# # # # #
# . . . #
# . . . #
# . . . #
# # # # #
`)
}
})
```
The micro:bit will look like it's showing 1 frame of the image by displaying the whole image when pick random is equal to 1. We can help the micro:bit randomly decide which image to use by pick random. The micro:bit will randomly pick the image to display with show LEDs and the pick random function.
```blocks
input.onGesture(Gesture.Shake, () => {
let img = Math.random(3)
if (img == 2) {
basic.showLeds(`
# # # # #
# . . . #
# . . . #
# . . . #
# # # # #
`)
} else if (img == 1) {
basic.showLeds(`
. . . . .
. # # # .
. # # # .
. # # # .
. . . . .
`)
}
})
```
The micro:bit will look like it's showing 1 frame of the image by displaying the whole image when pick random is not equal to 2 and not equal to 1. We can help the micro:bit randomly decide which image to use by pick random. The micro:bit will randomly pick the image to display with show LEDs and the pick random function.
```blocks
input.onGesture(Gesture.Shake, () => {
let img = Math.random(3)
if (img == 2) {
basic.showLeds(`
# # # # #
# . . . #
# . . . #
# . . . #
# # # # #
`)
} else if (img == 1) {
basic.showLeds(`
. . . . .
. # # # .
. # # # .
. # # # .
. . . . .
`)
} else {
basic.showLeds(`
. . . # #
# # . # .
. . # . .
# # . # .
. . . # #
`)
}
})
```
### ~avatar avatar
Excellent, you're ready to continue with the [challenges](/lessons/rock-paper-scissors/challenges)!
### ~

View File

@ -1,133 +0,0 @@
# rock paper scissors challenges
Coding challenges for rock paper scissors.
## Before we get started
Complete the following [guided activity](/lessons/rock-paper-scissors/activity) , your code should look like this:
```blocks
input.onGesture(Gesture.Shake, () => {
let img = Math.random(3)
if (img == 2) {
basic.showLeds(`
# # # # #
# . . . #
# . . . #
# . . . #
# # # # #
`)
} else if (img == 1) {
basic.showLeds(`
. . . . .
. # # # .
. # # # .
. # # # .
. . . . .
`)
} else {
basic.showLeds(`
. . . # #
# # . # .
. . # . .
# # . # .
. . . # #
`)
}
})
```
### Challenge 1
When the A button is pressed, increment the score by 1. You can select Game drawer then add change score by 1.
```blocks
input.onGesture(Gesture.Shake, () => {
let img = Math.random(2)
if (img == 2) {
basic.showLeds(`
# # # # #
# . . . #
# . . . #
# . . . #
# # # # #
`)
} else if (img == 1) {
basic.showLeds(`
. . . . .
. # # # .
. # # # .
. # # # .
. . . . .
`)
} else {
basic.showLeds(`
. . . # #
# # . # .
. . # . .
# # . # .
. . . # #
`)
}
})
input.onButtonPressed(Button.A, () => {
game.addScore(1)
})
```
* Click *run* to execute your code in the simulator
### Challenge 2
After incrementing the score, display the total number of wins you have.
```blocks
input.onGesture(Gesture.Shake, () => {
let img = Math.random(2)
if (img == 2) {
basic.showLeds(`
# # # # #
# . . . #
# . . . #
# . . . #
# # # # #
`)
} else if (img == 1) {
basic.showLeds(`
. . . . .
. # # # .
. # # # .
. # # # .
. . . . .
`)
} else {
basic.showLeds(`
. . . # #
# # . # .
. . # . .
# # . # .
. . . # #
`)
}
})
input.onButtonPressed(Button.A, () => {
game.addScore(1)
basic.showString("WINS:")
basic.showNumber(game.score())
})
```
* Run and compile the code to see if it works as expected.
### Challenge 3
You have successfully tracked and displayed the number of wins on the micro:bit! However, what about losses? Use the Game drawer to change score by -1 when button `B` is pressed.
* Run and compile the code to see if it works as expected.

View File

@ -1,74 +0,0 @@
# rock paper scissors quiz
shift an image horizontally across the display with offset.
## Name
## Directions
Use this activity document to guide your work in the [rock paper scissors tutorial](/lessons/rock-paper-scissors/activity).
Answer the questions while completing the tutorial. Pay attention to the dialogues!
## 1. Describe what `offset` does?
<br/>
## 2. Draw which LEDs are ON after running this code and the random number returned is 0
```blocks
let img = images.createImage(`
. . . . . # # # # # . . . . #
. # # # . # . . . # # # . # .
. # # # . # . . . # . # # . .
. # # # . # . . . # # # . # .
. . . . . # # # # # . . . . #
`)
let offset = Math.random(3) * 5
img.showImage(offset)
```
![](/static/mb/lessons/night-light-2.png)
<br/>
<br/>
## 3. Draw which LEDs are ON after running this code with an offset of 5. This would occur if the random number returned is 1.
```blocks
let img_ = images.createImage(`
. . . . . # # # # # . . . . #
. # # # . # . . . # # # . # .
. # # # . # . . . # . # # . .
. # # # . # . . . # # # . # .
. . . . . # # # # # . . . . #
`)
let offset_ = Math.random(3) * 5
img.showImage(offset)
```
![](/static/mb/lessons/night-light-2.png)
<br/>
<br/>
## 4. Draw which LEDs are ON after running this code with an offset of 10. This would occur if the random number returned is 2.
```blocks
let img_1 = images.createImage(`
. . . . . # # # # # . . . . #
. # # # . # . . . # # # . # .
. # # # . # . . . # . # # . .
. # # # . # . . . # # # . # .
. . . . . # # # # # . . . . #
`)
let offset_1 = Math.random(3) * 5
img.showImage(offset)
```
![](/static/mb/lessons/night-light-2.png)
<br/>

View File

@ -22,10 +22,10 @@ Learn how to declare a **Boolean** variable, `var t:= true` `var f:=false` for o
## Documentation
* **running time** : [read more...](/reference/input/running-time)
* **global variable** : [read more...](/reference/variables/globals)
* **Boolean** : [read more...](/reference/types/boolean)
* **variable** : [read more...](/blocks/variables)
* **Boolean** : [read more...](/blocks/logic/boolean)
* **on button pressed** : [read more...](/reference/input/on-button-pressed)
* **if** : [read more...](/reference/logic/if)
* **if** : [read more...](/blocks/logic/if)
* **show string** : [read more...](/reference/basic/show-string)
## Objectives

View File

@ -9,9 +9,9 @@ Overview of Blocks lessons for the BBC micro:bit.
## Science
* [Night Light](/lessons/night-light), dim the LEDs with set brightness
* [Hack your headphones](/lessons/hack-your-headphones), create music on the BBC micro:bit by hacking your headphones
* [Banana Keyboard](/lessons/banana-keyboard), create music with fruits
* [Telegraph](/lessons/telegraph), play the telegraph game between 2 BBC micro:bits
* [Hack your headphones](/projects/hack-your-headphones), create music on the BBC micro:bit by hacking your headphones
* [Banana Keyboard](/projects/banana-keyboard), create music with fruits
* [Telegraph](/projects/telegraph), play the telegraph game between 2 BBC micro:bits
* [Zoomer](/lessons/zoomer), measure the force with acceleration
* [Glowing pendulum](/lessons/glowing-pendulum), construct a pendulum that glows using acceleration
@ -38,7 +38,6 @@ Overview of Blocks lessons for the BBC micro:bit.
## Engineering
* [The Watch](/lessons/the-watch), design and create The Watch
* [Truth or dare](/lessons/truth-or-dare), a game that forces each player to reveal a secret or do something funny with if statement
* [Spinner](/lessons/spinner), spin the arrow with multiple if statements
* [Dice roll](/lessons/dice-roll), spin with more if statements

View File

@ -1,24 +0,0 @@
# telegraph lesson
display beautiful images on the BBC micro:bit.
## Topic
Telegraph
## Quick Links
* [activity](/lessons/telegraph/activity)
* [challenges](/lessons/telegraph/challenges)
## Prior learning/place of lesson in scheme of work
Learn how to convert your BBC micro:bit into a telegraph using a second BBC micro:bit as well as pin P1, P2, 3V, GND,
and crocodile clips (or spring clips). The connect BBC micro:bit uses pins P1, P2, 3V, GND.
## Objectives
* learn how to setup the BBC micro:bit with crocodile clips
* learn how to telegraph to another BBC micro:bit

View File

@ -1,23 +0,0 @@
# the watch lesson
display beautiful images on the BBC micro:bit.
![](/static/mb/lessons/the-watch-0.png)
## Topic
The Watch
## Quick Links
* [activity](/lessons/the-watch/activity)
## Prior learning/place of lesson in scheme of work
Learn how to design the BBC micro:bit watch with household supplies.
## Objectives
* learn how to design and make the watch with the BBC micro:bit

View File

@ -4,6 +4,6 @@ The editor is open source on GitHub under the MIT license. Contributions are wel
### Repos
* [microsoft/pxt-microbit](https://github.com/Microsoft/pxt-microbit), PXT target for BBC micro:bit, also includes the documentation.
* [microbit/pxt](https://github.com/Microsoft/pxt), programming experience toolkit (PXT)
* [microsoft/pxt-microbit](https://github.com/Microsoft/pxt-microbit), PXT target for BBC micro:bit
* [microsoft/pxt-microbit-core](https://github.com/Microsoft/pxt-microbit-core), Yotta module used to build the BBC micro:bit runtime

View File

@ -1,15 +1,46 @@
# Projects
# Ten Projects
![](/static/mb/projects/all10.png)
## [Flashing Heart](/projects/flashing-heart)
![](/static/mb/projects/a1-display.png)
## [Smiley Buttons](/projects/smiley-buttons)
![](/static/mb/projects/a2-buttons.png)
## [Love Meter](/projects/love-meter)
![](/static/mb/projects/a3-pins.png)
## [Rock Paper Scissors](/projects/rock-paper-scissors)
![](/static/mb/projects/a4-motion.png)
## [Compass](/projects/compass)
![](/static/mb/projects/a5-compass.png)
## [Hack your headphones](/projects/hack-your-headphones)
![](/static/mb/projects/a6-music.png)
## [Banana keyboard](/projects/banana-keyboard)
![](/static/mb/projects/a7-conductive.png)
## [Telegraph](/projects/telegraph)
![](/static/mb/projects/a8-network.png)
## [Radio](/projects/radio)
![](/static/mb/projects/a9-radio.png)
## [Watch](/projects/the-watch)
![](/static/mb/projects/a10-watch.png)
### @short Projects
### ~column
## Beginner
* [Rock Paper Scissors](/projects/rock-paper-scissors)
### ~
### ~column

View File

@ -1,34 +0,0 @@
## Getting started
• Go to https://m.pxt.io/
• To create a new project, click new Project
Tap or click Blocks.
## Step 1
Use [show leds](/reference/basic/showLeds) and make your code look like this:
```blocks
basic.showLeds(`
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`);
```
Once you are done coding, don't forget to run your code with the Play button.
## Step 2
Add a [pause](/reference/basic/pause) to wait and [clear screen](/reference/basic/clearScreen) to turn off the LEDs.
```blocks
basic.showLeds(`
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`);
basic.pause(500);
basic.clearScreen();
```

View File

@ -95,6 +95,6 @@ Tap your banana instrument to play sound against... the fruit!
### ~avatar boothing
Excellent, you're ready to continue with the [challenges](/lessons/banana-keyboard/challenges)!
Excellent, you're ready to continue with the [challenges](/projects/banana-keyboard-challenges)!
### ~

106
docs/projects/compass.md Normal file
View File

@ -0,0 +1,106 @@
# compass
![](/static/mb/projects/a5-compass.png)
Display the direction that the micro:bit is facing using the compass
### ~avatar avatar
Welcome! This guided tutorial will show you how to program a script that displays the direction the micro:bit is pointing. Let's get started!
### ~
## Step 1
Create a loop that will continuously update the reading of the compass.
```blocks
basic.forever(() => {
})
```
## Step 2
Store the reading of the micro:bit in a variable called `degrees`.
```blocks
basic.forever(() => {
let degrees = input.compassHeading()
})
```
## Step 3
If `degrees` is less than `45`, then the compass heading is mostly pointing toward North. Display `N` on the micro:bit.
```blocks
basic.forever(() => {
let degrees = input.compassHeading();
if (degrees < 45) {
basic.showString("N");
}
});
```
## Step 4
If `degrees` is less than 135, the micro:bit is mostly pointing East. Display `E` on the micro:bit.
```blocks
basic.forever(() => {
let degrees = input.compassHeading();
if (degrees < 45) {
basic.showString("N");
}
else if (degrees < 135) {
basic.showString("E");
}
});
```
## Step 5
If `degrees` is less than 225, the micro:bit is mostly pointing South. Display `S` on the micro:bit.
```blocks
basic.forever(() => {
let degrees = input.compassHeading();
if (degrees < 45) {
basic.showString("N");
}
else if (degrees < 135) {
basic.showString("E");
}
else if (degrees < 225) {
basic.showString("S");
}
});
```
## Step 6
If none of these conditions returned true, then the micro:bit must be pointing West. Display `W` on the micro:bit.
```blocks
basic.forever(() => {
let degrees = input.compassHeading();
if (degrees < 45) {
basic.showString("N");
}
else if (degrees < 135) {
basic.showString("E");
}
else if (degrees < 225) {
basic.showString("S");
}
else {
basic.showString("W");
}
});
```

View File

@ -0,0 +1,115 @@
# flashing heart
![](/static/mb/projects/a1-display.png)
### ~avatar avatar
```sim
basic.forever(() => {
basic.showLeds(`
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`);
basic.pause(500);
basic.clearScreen();
basic.pause(500);
})
```
Use the LEDs to display a flashing heart, and then create
an animation of a broken heart. :(
### ~
## Step 1
Use [show leds](/reference/basic/show-leds) and make your code look like this:
```blocks
basic.showLeds(`
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`);
```
## Step 2
Add a [pause](/reference/basic/pause) to wait and [clear screen](/reference/basic/clear-screen) to turn off the LEDs.
```blocks
basic.showLeds(`
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`);
basic.pause(500);
basic.clearScreen();
```
## Step 3
Put a [forever loop](/reference/basic/forever) around it.
```blocks
basic.forever(() => {
basic.showLeds(`
. # . # .
# # # # #
# # # # #
. # # # .
. . # . .`);
basic.pause(500);
basic.clearScreen();
})
```
## Step 4
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);
})
```
## Step 5
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);
})
```

View File

@ -1,4 +1,4 @@
# light beatbox activity
# hack your headphones challenges
Control sound with the light level.
@ -71,10 +71,3 @@ input.onButtonPressed(Button.A, () => {
* click *compile* and run your code on the micro:bit.
### ~avatar avatar
Excellent, you're ready to continue by connecting your headphones with these [challenges](/lessons/hack-your-headphones/activity)!
### ~

View File

@ -1,4 +1,4 @@
# hack your headphones activity
# hack your headphones
Hack your headphones
@ -52,10 +52,10 @@ You hacked your headphones!
### Step 6
Connect your micro:bit to your computer using your USB cable and program [light beatbox](/lessons/light-beatbox/activity) music on it. Press the reset button to restart your music player!
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](/lessons/light-beatbox/activity)!
Excellent, you're ready to continue with the [challenges](/projects/hack-your-headphones-challenges)!
### ~

View File

@ -0,0 +1,50 @@
# love meter
![](/static/mb/projects/a3-pins.png)
Use pins P0, P1 and P2 to change the display by creating a circuit with your body.
## Step 1
Use [on pin pressed](/reference/input/on-pin-pressed) to show a random number
when pin P0 is pressed (hold the GND pin with other hand):
```blocks
input.onPinPressed(TouchPin.P0, () => {
basic.showNumber(Math.random(11));
});
```
## Step 2
Show a string when pin P1 is pressed:
```blocks
input.onPinPressed(TouchPin.P0, () => {
basic.showNumber(Math.random(11));
});
input.onPinPressed(TouchPin.P1, () => {
basic.showString("LOVE?");
});
```
## Step 3
Show a heart when pin P2 is pressed:
```blocks
input.onPinPressed(TouchPin.P0, () => {
basic.showNumber(Math.random(11));
});
input.onPinPressed(TouchPin.P1, () => {
basic.showString("LOVE?");
});
input.onPinPressed(TouchPin.P2, () => {
basic.showLeds(`
. # # # .
# # # # #
# # # # #
. # # # .
. . # . .
`);
});
```

View File

@ -0,0 +1,88 @@
# Challenge
### ~avatar avatar
Welcome! The activity will teach you how to use the acceleration of the 1st micro:bit and to visualize the acceleration on the 2nd micro:bit.
Let's get started!
### ~
Let's measure `acceleration (mg)` and then `send number`. `Acceleration` is measured in **milli-gravities**, so a value of -1000 is equivalent to -1g or -9.81m/s^2. We will be able to get the acceleration value (g-force), in the specified "x" dimension. `Send number` will broadcast a number data packet to other micro:bits connected via radio.
```blocks
radio.sendNumber(input.acceleration(Dimension.X));
```
### ~
We want to display the acceleration forever. In order to do so, we need a `forever` loop. A forever loop will repeat code in the background forever.
```blocks
basic.forever(() => {
radio.sendNumber(input.acceleration(Dimension.X));
});
```
### ~
We want to register code to run when a packet is received over radio. We can implement this code by adding `on data received`.
```blocks
basic.forever(() => {
radio.sendNumber(input.acceleration(Dimension.X))
})
radio.onDataReceived(() => {
})
```
### ~
Finally, we want to chart the acceleration. So we must first implement `plot bar graph`. `Plot Bar Graph` will display a vertical bar graph based on the value and high value. In order to transfer the receive the number from the 1st micro:bit, we must implement `receive number` to constantly display a vertical bar graph based on the value. Remember, the value will equal to the micro:bit's acceleration in the "x" direction.
```blocks
basic.forever(() => {
radio.sendNumber(input.acceleration(Dimension.X))
})
radio.onDataReceived(() => {
led.plotBarGraph(radio.receiveNumber(), 1023)
})
```
### ~
Notice that moving the micro:bit the farthest direction in the x direction will be -1023 on the charting beneath the simulator. The second observation will be that the LEDs will be full brightness on the 2nd micro:bit. There is a single LED turned on with the 1st micro:bit. Additionally, the graphs will reflect 0 acceleation for the 1st micro:bit. In this scenario, if you are adjusting the acceleration in the simualator, you are also changing your chart that will be produced.
![](/static/mb/acc.png)
### ~
NOTE: The colors of the charts reflect the color of the micro:bit simulator. In this instance, the micro:bits are blue and green. So the colors of the line graphs reflect the colors of the micro:bit
### ~
After running this simulation several seconds by moving the micro:bit side to side in the x direction, you are ready to graph or chart the accceleration of the micro:bit. We want a printout of our acceleration on Excel. We will graph the fluctuating acceleration of the simulation experiment.
![](/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.
![](/static/mb/data3.png)
Use the Recommended Charts command on the Insert tab to quickly create a chart thats just right for your data.
* Select the data that you want to include in your chart.
* Click Insert > Recommended Charts.
![](/static/mb/lessons/chart1.png)
* On the Recommended Charts tab, scroll through the list of chart types that Excel recommends for your data. Pick the **scatter plot**.
![](/static/mb/chart_title.png)
* Use the Chart Elements, Chart Styles, and Chart Filters buttons next to the upper-right corner of the chart to add chart elements like axis titles or data labels, to customize the look of your chart
![](/static/mb/elements_styles_filters.png)
### ~
Have fun reviewing your simulation and analyze the acceleration by chart the Excel data using Excel.
* Connect the first micro:bit to your computer using your USB cable and run the charting script on it.
* Connect the second micro:bit to your computer using your USB cable and run the charting script on it.
* The first person and second person take turns tilting the micro:bit in the "x" direction while the other player charts the data on the micro:bit!
* Review and analyze the actual micro:bit device acceleration data on Excel
* Display acceleration with y or z using plot bar graph by changing acceleration from "x" to "y" or "z"

68
docs/projects/radio.md Normal file
View File

@ -0,0 +1,68 @@
# radio
Measure the acceleration on the micro:bit in the "x" direction.
### ~avatar avatar
Welcome! This activity will teach how to use the micro:bit to chart the acceleration in the "x" direction. Let's get started!
### ~
Let's measure `acceleration (mg)` in the "x" direction. Get the acceleration value (milli g-force), in one of three specified dimensions.
```blocks
input.acceleration(Dimension.X)
```
### ~
Use the plot bar chart to visualize the acceleration on the LED screen of the micro:bit in the specified range. You implement plot Bar Graph to display a vertical bar graph based on the "value" and "high" value. Then you must insert acceleration in the X dimension to measure the acceleration.
```blocks
basic.forever(() => {
led.plotBarGraph(input.acceleration(Dimension.X), 0)
})
```
### ~
Notice that moving the micro:bit in the simulator from left to right (x direction) changes the values beneath the micro:bit in a range from 1023 to -1023 as measured in milli-gravities. By hovering over the micro:bit from left to right, you can observe changing values beneath the micro:bit simulator. Also, the LEDs shown on the Bar Graph fluctates based on the movement of the micro:bit simulator in the x direction. The line underneath the micro:bit simulator reflect the acceleration in the x direction.
NOTE: The colors of the charts reflect the color of the micro:bit simulator. In this instance, the micro:bit is yellow. So the color of the data line reflects the color of the micro:bit
![](/static/mb/data4.png)
### ~
Vigorously move the micro:bit in the micro:bit simulatator by moving the micro:bit image from side to side. Every time the micro:bit moves in the x direction in the simulator, you are generating data points that can be reviewed in Excel. The more attempts to move the micro:bit from side to side, the more data being saved in Excel. After you have vigarously moved the micro:bit simulator from side to side for a sufficient amount of time, you are ready to graph or chart the accceleration of the micro:bit. We want a printout of our acceleration on Excel that can be graphed in Excel.
### ~
We want to chart the data collected by using a tool in Excel.
The final part of this experiment is opening and reviewing the data in the Excel CSV file. Simply click on the line beneath the simulator. A CSV file will be generated to display the data points collected by moving the micro:bit in the X direction. Then click or tap on the data Excel file that was downloaded to your local ``Downloads`` Folder.
### ~
First, click or tap on the first two columns (A, B) to include the time of the data being collected; b) the results of acceleration data on the micro:bit
![](/static/mb/data7.png)
Use the Recommended Charts command on the Insert tab to quickly create a chart thats just right for your data.
* Select the data that you want to include in your chart.
* Click Insert > Recommended Charts.
![](/static/mb/lessons/chart1.png)
* On the Recommended Charts tab, scroll through the list of chart types that Excel recommends for your data. Pick the **scatter plot**.
### ~avatar avatar
Excellent, you're ready to continue with the [challenges](/projects/radio-challenges)
### ~

View File

@ -1,5 +1,7 @@
# rock paper scissors
![](/static/mb/projects/a4-motion.png)
### ~avatar avatar
```sim
@ -37,8 +39,6 @@ In this project, you will build a Rock Paper Scissors game with the BBC micro:bi
You can play the game with a friend who has it on a micro:bit.
You can also play it with friends who are just using their hands.
## [START PROJECT](/#follow:/projects/rock-paper-scissors)
### ~

View File

@ -0,0 +1,69 @@
# smiley buttons
![](/static/mb/projects/a2-buttons.png)
Use buttons to show a smiley or frowny face.
## Step 1
Use [show leds](/reference/basic/show-leds) to make a smiley face:
```blocks
basic.showLeds(`
. # . # .
. # . # .
. . . . .
# . . . #
. # # # .`);
```
## Step 2
Add an input block for when [button A is pressed](/reference/input/button-is-pressed), and put a
frowny face inside it:
```blocks
basic.showLeds(`
. # . # .
. # . # .
. . . . .
# . . . #
. # # # .`);
input.onButtonPressed(Button.A, () => {
basic.showLeds(`
. # . # .
. # . # .
. . . . .
. # # # .
# . . . #`);
});
```
## Step 3
Now add blocks so that when [button B is pressed](/reference/input/button-is-pressed), a smiley appears:
```blocks
basic.showLeds(`
. # . # .
. # . # .
. . . . .
# . . . #
. # # # .`);
input.onButtonPressed(Button.A, () => {
basic.showLeds(`
. # . # .
. # . # .
. . . . .
. # # # .
# . . . #`);
});
input.onButtonPressed(Button.B, () => {
basic.showLeds(`
. # . # .
. # . # .
. . . . .
# . . . #
. # # # .`);
});
```

View File

@ -4,13 +4,9 @@ Build a telgraph.
# 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 [guided tutorial](/lessons/telegraph/activity), your hack should look like this:
Complete the following [guided tutorial](/projects/telegraph), your hack should look like this:
![](/static/mb/lessons/telegraph-0.png)
@ -109,6 +105,6 @@ Your telegraph is ready!
### Step 7
* Connect the first micro:bit to your computer using your USB cable and run the [telegraph](/nnudbr) script on it.
* Connect the second micro:bit to your computer using your USB cable and run the [telegraph](/nnudbr) script on it.
* Connect the first micro:bit to your computer using your USB cable and put the telegraph script on it.
* Connect the second micro:bit to your computer using your USB cable and run the telegraph script on it.
* The first person and second person take turns pressing button A to play the telegraph game!

View File

@ -70,6 +70,6 @@ Using the 4th crocodile clip, connect the unattached end of the crocodile clip o
### ~avatar avatar
Excellent, you're ready to continue with the [challenges](/lessons/telegraph/challenges)!
Excellent, you're ready to continue with the [challenges](/projects/telegraph-challenges)!
### ~

View File

@ -1,8 +1,6 @@
# The watch activity
![](/static/mb/projects/a10-watch.png)
Control images with variables.
# micro:bit watch
# the watch
![](/static/mb/lessons/the-watch-0.png)
@ -152,7 +150,7 @@ Your watch is ready!
### ~avatar avatar
Excellent, you're ready to continue with the [challenges](/lessons/rock-paper-scissors/activity)!
Excellent, you're ready to continue with the [challenges](/projects/rock-paper-scissors)!
### ~

View File

@ -1,10 +1,6 @@
# Reference
# Micro:bit APIs
```namespaces
for (let i = 0;i<5;++i) {}
if (true){}
let x = 0;
Math.random(5);
basic.showNumber(0);
input.onButtonPressed(Button.A, () => {
@ -21,8 +17,8 @@ images.createImage(`
. . . . .
`);
pins.digitalReadPin(DigitalPin.P0);
serial.writeValue(x, 0);
serial.writeNumber(0);
control.inBackground(() => {
});
```
```

View File

@ -21,10 +21,6 @@ basic.showLeds(`
basic.clearScreen()
```
### Lessons
[blink](/lessons/blink), [flashing heart](/lessons/flashing-heart), [screen wipe](/lessons/screen-wipe)
### See also
[set brightness](/reference/led/set-brightness), [unplot](/reference/led/unplot), [plot](/reference/led/plot), [Image](/reference/images/image), [clear](/reference/basic/clear-screen)

View File

@ -63,11 +63,7 @@ input.onButtonPressed(Button.A, () => {
})
```
### Lessons
[blink](/lessons/blink), [snowflake-fall](/lessons/snowflake-fall), [flashing-heart](/lessons/flashing-heart)
### See also
[while](/reference/loops/while), [on button pressed](/reference/input/on-button-pressed), [in background](/reference/control/in-background)
[while](/blocks/loops/while), [on button pressed](/reference/input/on-button-pressed), [in background](/reference/control/in-background)

View File

@ -24,11 +24,7 @@ for (let i = 0; i < 5; i++) {
}
```
### Lessons
[blink](/lessons/blink), [lucky 7](/lessons/lucky-7), [smiley](/lessons/smiley), [flashing heart](/lessons/flashing-heart)
### See also
[while](/reference/loops/while), [running time](/reference/input/running-time), [for](/reference/loops/for)
[while](/blocks/loops/while), [running time](/reference/input/running-time), [for](/blocks/loops/for)

View File

@ -62,8 +62,3 @@ basic.showAnimation(`
Use [forever](/reference/basic/forever) to show an animation over and over.
### ~
### Lessons
[smiley](/lessons/smiley), [snowflake fall](/lessons/snowflake-fall), [rotation animation](/lessons/rotation-animation)

View File

@ -1,6 +1,6 @@
# Show LEDs
Display an image on the BBC micro:bit's [LED screen](/device/screen).
Shows a picture on the [LED screen](/device/screen).
```sig
basic.showLeds(`
@ -15,13 +15,13 @@ basic.showLeds(`
### Parameters
* `leds` is a [String](/reference/types/string) that shows which LEDs are on and off.
* `ms` is an optional [Number](/reference/types/number) that shows how many milliseconds to wait after showing a picture.
If you are programming with blocks, `ms` starts out as 400 milliseconds.
* `leds` is a [string](/reference/types/string) that controls which LEDs are on and off.
* `interval` is an optional [number](/reference/types/number) that means how many milliseconds to wait after showing a picture.
If you are programming with blocks, `interval` is set at 400 milliseconds.
### Example
Open the `basic` card in the Block Editor and select the `show leds` blocks.
This program shows a picture with the ``show leds`` function.
```blocks
basic.showLeds(`
@ -34,11 +34,12 @@ basic.showLeds(`
)
```
If you are programming in JavaScript, `#` means an LED that is turned on and `.` means an LED that is turned off.
### ~hint
### Lessons
If you are programming in JavaScript, `#` means an LED that is turned
on and `.` means an LED that is turned off.
[smiley](/lessons/smiley), [flashing heart](/lessons/flashing-heart), [magic logo](/lessons/magic-logo)
### ~
### See also

View File

@ -28,7 +28,7 @@ basic.showNumber(x)
### Example: count to 5
This example uses a [for](/reference/loops/for) loop to show numbers ``0`` through ``5`` on the screen:
This example uses a [for](/blocks/loops/for) loop to show numbers ``0`` through ``5`` on the screen:
~~~~blocks
for (let i = 0; i < 6; i++) {
@ -42,11 +42,7 @@ for (let i = 0; i < 6; i++) {
* Use [show string](/reference/basic/show-string) to show a [String](/reference/types/string) with letters on the screen.
* Use [show animation](/reference/basic/show-animation) to show a group of pictures on the screen, one after another.
### Lessons
* [lucky 7](/lessons/lucky-7)
### See also
[show string](/reference/basic/show-string), [show animation](/reference/basic/show-animation), [Number](/reference/types/number), [math library](/reference/math)
[show string](/reference/basic/show-string), [show animation](/reference/basic/show-animation), [Number](/reference/types/number), [math](/blocks/math)

View File

@ -31,10 +31,6 @@ basic.showString(s)
* Use [show number](/reference/basic/show-number) to show a number on the [LED screen](/device/screen).
* Use [show animation](/reference/basic/show-animation) to show a group of pictures on the screen, one after another.
### Lessons
[answering machine](/lessons/answering-machine), [rock paper scissors](/lessons/rock-paper-scissors), [love meter](/lessons/love-meter)
### See also
[String](/reference/types/string), [show number](/reference/basic/show-number), [show animation](/reference/basic/show-animation)

View File

@ -51,5 +51,5 @@ input.onButtonPressed(Button.A, () => {
### See also
[while](/reference/loops/while), [forever](/reference/basic/forever), [on button pressed](/reference/input/on-button-pressed)
[while](/blocks/loops/while), [forever](/reference/basic/forever), [on button pressed](/reference/input/on-button-pressed)

View File

@ -1,6 +1,19 @@
# Change Score By
The code below shows a simple game where the user gets to press the button ``A`` as much times as possible and the score will display on the screen.
Add the amount you say to the score for the game.
```sig
game.addScore(1)
```
### Parameters
* a [number](/reference/types/number) that means how much to add to the score. A negative number means to subtract from the score.
### Examples
This program is a simple game.
Press button ``A`` as much as possible.
At the end of 10 seconds, the program will show your score.
```blocks
input.onButtonPressed(Button.A, () => {
@ -9,23 +22,6 @@ input.onButtonPressed(Button.A, () => {
game.startCountdown(10000)
```
### Score
When a player achieves a goal, you can increase the game score
* add score points to the current score
```
export function addScore(points: number)
```
* get the current score value
```
export function score() : number
```
### Lessons
[game of chance](/lessons/game-of-chance), [game counter](/lessons/game-counter)
### See Also
[score](/reference/game/score), [start countdown](/reference/game/start-countdown)

View File

@ -19,8 +19,3 @@ Sprite will change the y position by this number
```
export function changeYBy(_this: micro_bitSprites.LedSprite, y: number)
```
### Lessons
[game of chance](/lessons/game-of-chance) | [game counter](/lessons/game-counter)

View File

@ -11,7 +11,7 @@ input.onButtonPressed(Button.A, () => {
game.startCountdown(10000)
```
### [Create sprite](/functions/game-library/create-sprite)
### [Create sprite](/reference/game/create-sprite)
Create sprite with x, y coordinates and returns a LED Sprite. Create a new LED sprite.
@ -21,7 +21,7 @@ Create sprite with x, y coordinates and returns a LED Sprite. Create a new LED s
export function createSprite(x: number, y: number) : micro_bitSprites.LedSprite
```
### [Move](/functions/game-library/move)
### [Move](/reference/game/move)
Sprite move by a certain number
@ -31,7 +31,7 @@ Sprite move by a certain number
export function move(_this: micro_bitSprites.LedSprite, leds: number)
```
### [Turn](/functions/game-library/turn)
### [Turn](/reference/game/turn)
Rotates a sprite to the right by a certain number of degrees
@ -47,7 +47,7 @@ Rotates a sprite to the left by a certain number of degrees
export function turnLeft(_this: micro_bitSprites.LedSprite, degrees: number)
```
### [Change](/functions/game-library/change)
### [Change](/reference/game/change)
Sprite will change the x position by this number
@ -63,7 +63,7 @@ Sprite will change the y position by this number
export function changeYBy(_this: micro_bitSprites.LedSprite, y: number)
```
### [Set](/functions/game-library/set)
### [Set](/reference/game/set)
Sprite will change the x position by this number
@ -79,7 +79,7 @@ Sprite will change the y position by this number
export function changeYBy(_this: micro_bitSprites.LedSprite, y: number)
```
### [If on edge, bounce](/functions/game-library/if-on-edge-bounce)
### [If on edge, bounce](/reference/game/if-on-edge-bounce)
Sprite - If the sprite is on the edge, the sprite will bounce
@ -89,7 +89,7 @@ Sprite - If the sprite is on the edge, the sprite will bounce
export function ifOnEdge_Bounce(_this: micro_bitSprites.LedSprite)
```
### [Change score by](/functions/game-library/change-score-by)
### [Change score by](/reference/game/change-score-by)
When a player achieves a goal, you can increase the game score
@ -101,7 +101,7 @@ When a player achieves a goal, you can increase the game score
export function addScore(points: number)
```
### [Score](/functions/game-library/score)
### [Score](/reference/game/score)
* set the current score to a particular value.
@ -117,7 +117,7 @@ export function setScore(value: number)
export function score() : number
```
### [Countdown](/functions/game-library/start-countdown)
### [Countdown](/reference/game/start-countdown)
If your game has a time limit, you can start a countdown in which case `game->current time` returns the remaining time.
@ -129,7 +129,7 @@ If your game has a time limit, you can start a countdown in which case `game->cu
export function startCountdown(ms: number)
```
### [Game over](/functions/game-library/game-over)
### [Game over](/reference/game/game-over)
If the `life` reaches zero or the time expires (see countdown), the game enters the **game over** mode. When the game is over, `game->is running` returns false
@ -146,8 +146,3 @@ You can also end the game by calling the `game -> game over` function:
```
game.gameOver()
```
### Lessons
[game of chance](/lessons/game-of-chance) | [game counter](/lessons/game-counter)

View File

@ -1,24 +1,24 @@
# Game Over
The game library
End the game and show the score.
The game library supports simple single-player time-based games. The game can end the game by calling the `game over` function
### Example
## Block Editor
This program asks you to pick a button.
If you press button `A`, the program says `YOU WIN!`.
If you press button `B`, it shows an animation and ends the game.
You can end the game by calling the `game over ` function. In this example, if BBC micro:bit's answer to the question is GAME OVER, GAME OVER will be displayed to end the game.
![](/static/mb/game-library/game-over-0.png)
## KindScript
You can end the game by calling the `game -> game over` function:
```
game.gameOver()
```blocks
basic.showString("PICK A BUTTON");
input.onButtonPressed(Button.A, () => {
basic.showString("YOU WIN!");
});
input.onButtonPressed(Button.B, () => {
game.gameOver();
});
```
### Lessons
[game of chance](/lessons/game-of-chance)
### See Also
[score](/reference/game/score),
[change score by](/reference/game/change-score-by), [start countdown](/reference/game/start-countdown)

View File

@ -5,8 +5,3 @@ Sprite move by a certain number of LEDs
```
export function move(_this: micro_bitSprites.LedSprite, leds: number)
```
### Lessons
[game of chance](/lessons/game-of-chance) | [game counter](/lessons/game-counter)

View File

@ -11,8 +11,3 @@ Reports the y position of a sprite on the LED screen
```
export function y(_this: micro_bitSprites.LedSprite) : number
```
### Lessons
[game of chance](/lessons/game-of-chance) | [game counter](/lessons/game-counter)

View File

@ -25,8 +25,3 @@ Reports the current direction of a sprite on the LED screen
```
export function direction(_this: micro_bitSprites.LedSprite) : number
```
### Lessons
[game of chance](/lessons/game-of-chance) | [game counter](/lessons/game-counter)

View File

@ -1,49 +1,25 @@
# Score
The game library supports simple single-player games. The player has a **score**.
Find the number of points scored in your game.
The code below shows a simple game where the user gets to press the button ``A`` as much times as possible in 10 seconds.
```sig
game.score()
```
### Example
This program adds one point to your score every time you press button
`A`, and shows an animation. Then it waits 500 milliseconds (half a
second) and shows your score.
```blocks
input.onButtonPressed(Button.A, () => {
game.addScore(1)
})
game.startCountdown(10000)
game.addScore(1);
basic.pause(500);
basic.showNumber(game.score());
});
```
### Score
When a player achieves a goal, you can increase the game score
* add score points to the current score
```
export function addScore(points: number)
```
* set the current score to a particular value.
```
export function setScore(value: number)
```
* get the current score value
```
export function score() : number
```
### Countdown
If your game has a time limit, you can start a countdown in which case `game->current time` returns the remaining time.
* start a countdown with the maximum duration of the game in milliseconds.
```
export function startCountdown(ms: number)
```
### Lessons
[game of chance](/lessons/game-of-chance), [game counter](/lessons/game-counter)
### See Also
[change score by](/reference/game/score), [start countdown](/reference/game/start-countdown)

View File

@ -1,47 +1,29 @@
# Start Countdown
The code below shows a simple game where the user gets to press the button ``A`` as much times as possible in 10 seconds.
Start counting down time from the number of milliseconds you say.
```sig
game.startCountdown(1000)
```
### Parameters
* a [number](/reference/types/number) that means how many milliseconds to count down (one second is 1000 milliseconds)
### Examples
This program is a simple game.
Press button ``A`` as much as possible.
At the end of 10 seconds, the program will show your score.
```blocks
input.onButtonPressed(Button.A, () => {
game.addScore(1)
})
game.startCountdown(10000)
```
### Score
### See Also
When a player achieves a goal, you can increase the game score
* add score points to the current score
```
export function addScore(points: number)
```
* set the current score to a particular value.
```
export function setScore(value: number)
```
* get the current score value
```
export function score() : number
```
### Countdown
If your game has a time limit, you can start a countdown in which case `game->current time` returns the remaining time.
* start a countdown with the maximum duration of the game in milliseconds.
```
export function startCountdown(ms: number)
```
### Lessons
[bop it](/lessons/bop-it) | [game of chance](/lessons/game-of-chance) | [game counter](/lessons/game-counter)
[score](/reference/game/score), [change score by](/reference/game/change-score-by)

View File

@ -6,7 +6,3 @@ Reports true if sprite is touching specified sprite
export function isTouching(_this: micro_bitSprites.LedSprite, other: micro_bitSprites.LedSprite) : boolean
```
### Lessons
[game of chance](/lessons/game-of-chance) | [game counter](/lessons/game-counter)

View File

@ -12,7 +12,3 @@ Rotates a sprite to the left by a certain number of degrees
export function turnLeft(_this: micro_bitSprites.LedSprite, degrees: number)
```
### Lessons
[game of chance](/lessons/game-of-chance) | [game counter](/lessons/game-counter)

View File

@ -29,10 +29,6 @@ input.onGesture(Gesture.Shake, () => {
})
```
### Lessons
[rock paper scissors](/lessons/rock-paper-scissors), [digital pet](/lessons/digital-pet), [offset-image](/lessons/offset-image)
### See also
[show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/image/show-image), [scroll image](/reference/image/scroll-image)

View File

@ -8,7 +8,7 @@ An *Image* is a matrix of pixels to show on the [LED screen](/device/screen)
### Block Editor: Show LEDs
To display an image using the [Block Editor](/blocks/editor):
To display an image:
* click `Basic` , `Show LEDs`, and tap on the LEDs`
* when you're done, return to your code
@ -21,10 +21,6 @@ You should see code similar to this:
To create an image that you can later modify, see the [create image](/reference/images/create-image) function.
### Block editor: create and show images
To create images using the [Block editor](/blocks/editor):
1. Click the **Images** category on the left.
2. Drag and drop the **show image** block into your code.
@ -46,10 +42,6 @@ You should see code similar to this:
* [show image](/reference/images/show-image): show an image on the screen
* [scroll image](/reference/images/scroll-image): scroll an image on the screen
### Lessons
* [smiley](/lessons/smiley)
### See also
[Show LEDs](/reference/basic/show-leds), [create image](/reference/images/create-image), [show image](/reference/images/show-image), [LED screen](/device/screen)

View File

@ -21,7 +21,7 @@ To figure out the ``x``, ``y`` coordinates, see [LED screen](/device/screen).
### Returns
* [Boolean](/reference/types/boolean) - `true` for on and `false` for off
* [Boolean](/blocks/logic/boolean) - `true` for on and `false` for off
### Example

View File

@ -31,10 +31,6 @@ let img = images.createImage(`
img.plotFrame(1)
```
### Lessons
[smiley](/lessons/smiley), [flashing heart](/lessons/flashing-heart), [magic logo](/lessons/magic-logo)
### See also
[create image](/reference/images/create-image), [show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image)

View File

@ -31,10 +31,6 @@ let img = images.createImage(`
img.plotImage(0)
```
### Lessons
[smiley](/lessons/smiley), [flashing heart](/lessons/flashing-heart), [magic logo](/lessons/magic-logo)
### See also
[create image](/reference/images/create-image), [show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image)

View File

@ -14,7 +14,7 @@ export function setPixel(_this: micro_bit.Image, x: number, y: number, value: bo
* x - [Number](/reference/types/number); the *x coordinate* or horizontal position of a pixel in an [image](/reference/images/image)
* x - [Number](/reference/types/number); the *y coordinate* or vertical position of a pixel in an [image](/reference/images/image)
* value -[Boolean](/reference/types/boolean); the on/off state of a pixel; `true` for on, `false` for off
* value -[Boolean](/blocks/logic/boolean); the on/off state of a pixel; `true` for on, `false` for off
### x, y coordinates?

View File

@ -31,10 +31,6 @@ let img = images.createImage(`
img.showFrame(1)
```
### Lessons
[smiley](/lessons/smiley), [flashing heart](/lessons/flashing-heart), [magic logo](/lessons/magic-logo)
### See also
[create image](/reference/images/create-image), [show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image)

View File

@ -29,7 +29,7 @@ img.showImage(0)
### Example: display numbers 1-5
The following example creates an image with 5 frames and then uses a [for loop](/reference/loops/for) to show each frame on the screen:
The following example creates an image with 5 frames and then uses a [for loop](/blocks/loops/for) to show each frame on the screen:
```
let img2 = images.createImage(`
@ -45,10 +45,6 @@ for (let i = 0; i < 5; i++) {
}
```
### Lessons
[rock paper scissors](/lessons/rock-paper-scissors), [digital pet](/lessons/digital-pet), [offset-image](/lessons/offset-image)
### See also
[show animation](/reference/basic/show-animation), [image](/reference/images/image), [create image](/reference/images/create-image), [scroll image](/reference/images/scroll-image)

View File

@ -38,7 +38,7 @@ let w = img.width()
### Example: show each frame
The following example uses the `width` function with a [for](/reference/loops/for) loop to show each image frame on the screen:
The following example uses the `width` function with a [for](/blocks/loops/for) loop to show each image frame on the screen:
```
let img2 = images.createImage(`

View File

@ -2,48 +2,41 @@
Get the acceleration value (milli g-force), in one of three specified dimensions.
Find the acceleration of the micro:bit (how fast it is speeding up or slowing down).
```sig
input.acceleration(Dimension.X);
```
## ~hint
You measure acceleration with the **milli-g**, which is 1/1000 of a **g**.
A **g** is as much acceleration as you get from Earth's gravity.
## ~
### Parameters
* dimension : [String](/reference/types/string) - one of three values specifying the axis of acceleration: ``x`` (left/right); ``y`` (forward/backwards); ``z`` (up/down)
* which direction you are checking for acceleration, either `Dimension.X` (left and right), `Dimension.Y` (forward and backward), or `Dimension.Z` (up and down)
### Returns
* [Number](/reference/types/number) - acceleration, in milli-gravities. When the micro:bit is laying flat with the screen up, x=0, y=0 and z=-1023.
* a [number](/reference/types/number) that means the amount of acceleration. When the micro:bit is lying flat on a surface with the screen pointing up, `x` is `0`, `y` is `0`, and `z` is `-1023`.
### Example: bar chart
Use the ``plot bar chart`` to visual the acceleration on the LED screen.
This example shows the acceleration of the micro:bit with a bar graph.
```blocks
basic.forever(() => {
led.plotBarGraph(input.acceleration("x"), 1023)
led.plotBarGraph(input.acceleration(Dimension.X), 1023)
})
```
### Example: micro:bit leveller
The following example uses the `acceleration` and the `plot` function to help you move the micro:bit until it's level (the centre LED is *on* when the device is level). When running this code in a web browser, move your mouse to simulate the accelerometer.
```blocks
basic.forever(() => {
let ax = input.acceleration(Dimension.X)
let x = pins.map(-1023, 1023, 0, 4, ax)
let ay = input.acceleration("y")
let y = pins.map(-1023, 1023, 0, 4, ay)
basic.clearScreen()
led.plot(x, y)
})
```
### Lessons
[zoomer](/lessons/zoomer)
### See also
[compass-heading](/reference/input/compass-heading), [lightlevel](/reference/input/lightlevel)
[compass-heading](/reference/input/compass-heading), [lightlevel](/reference/input/light-level)

View File

@ -12,11 +12,11 @@ input.buttonIsPressed(Button.A);
### Returns
* [Boolean](/reference/types/boolean) that is `true` if the button you are checking is pressed, `false` if it is not pressed.
* [Boolean](/blocks/logic/boolean) that is `true` if the button you are checking is pressed, `false` if it is not pressed.
### Example
This program uses an [if](/reference/logic/if) to run
This program uses an [if](/blocks/logic/if) to run
one part of the program if the `A` button is pressed, and
another part if it is not pressed.
@ -33,11 +33,7 @@ basic.forever(() => {
})
```
### Lessons
[zoomer](/lessons/zoomer)
### See also
[on button pressed](/reference/input/on-button-pressed), [if](/reference/logic/if), [forever](/reference/basic/forever)
[on button pressed](/reference/input/on-button-pressed), [if](/blocks/logic/if), [forever](/reference/basic/forever)

View File

@ -1,6 +1,10 @@
# Compass Heading
Get the compass heading of the micro:bit in degrees. Your micro:bit has a built-in **magnetometer** so it can your direction with respect to the North Magnetic Pole.
Find which direction on a compass the micro:bit is facing.
The micro:bit measures the **compass heading** from `0` to `360`
degrees with its **magnetometer** chip. Different numbers mean north,
east, south, and west.
```sig
input.compassHeading();
@ -8,15 +12,12 @@ input.compassHeading();
### Returns
* [Number](/reference/types/number) - the heading in degrees (0 to 360 degrees). If the compass is calibrating, it returns ``-1003``.
## Simulator
Calibration does not work on the simulator.
* a [number](/reference/types/number) from `0` to `360` degrees, which means the compass heading. If the compass isn't ready, it returns `-1003`.
### Example
The following code gets the compass heading and stores it in the `degrees` variable:
This program finds the compass heading and stores it in the
`degrees` variable.
```blocks
let degrees = input.compassHeading()
@ -24,13 +25,16 @@ let degrees = input.compassHeading()
### ~hint
When running code with this function in a web browser, click and drag the on-screen compass needle to change heading.
When you run a program that uses this function in a browser, click and drag
the compass needle on the screen to change the compass heading.
### ~
### Example: compass
The following example gets the `compass heading` and then displays a letter depending on the value of `degrees`: N for north, E for East, S for South, and W for West.
This program finds the compass heading and then shows a letter
that means whether the micro:bit is facing north (N), south (S),
east (E), or west (W).
```blocks
basic.forever(() => {
@ -47,17 +51,14 @@ basic.forever(() => {
### Calibration
On the first use of the compass, the **calibration** procedure will automatically start. The user must draw a circle with the device until it is fully calibrated.
Every time you start to use the compass (for example, if you have just
turned the micro:bit on), the micro:bit will start to **calibrate**
(adjust itself). It will ask you to draw a circle by tilting the
micro:bit.
An enclosure made from metal, or using in proximity of metal objects, might affect the accuracy of the reading and calibration.
During calibration, ``compass heading`` returns ``-1003``.
### Lessons
[compass](/lessons/compass)
If you are calibrating or using the compass near metal, it might
confuse the micro:bit.
### See also
[acceleration](/reference/input/acceleration)

View File

@ -43,8 +43,6 @@ basic.forever(() => {
})
```
### Lessons
### See also
[acceleration](/reference/input/acceleration), [compass-heading](/reference/input/compass-heading)

View File

@ -1,22 +1,30 @@
# Magnetic Force
Get the magnetic force (micro Teslas), in one of three specified dimensions.
Find the amount of magnetic force (the strength of a magnet) in the direction you say.
```sig
input.magneticForce(Dimension.X);
```
## ~hint
The micro:bit measures magnetic force with **microteslas**.
## ~
### Parameters
* dimension : [String](/reference/types/string) - one of three values specifying the axis of the force: ``x`` (left/right); ``y`` (forward/backwards); ``z`` (up/down); ``strength`` (the length of the vector)
* a [string](/reference/types/string) that says which direction the micro:bit should measure magnetic force in: either `x` (the left-right direction), `y` (the forward/backward direction), or `z` (the up/down direction)
### Returns
* [Number](/reference/types/number) - magnetic force, in micro-Teslas.
* a [number](/reference/types/number) of microteslas that means the strength of the magnet
### Example: metal detector
The following example uses the `magnetic force` to control the brightness of the screen. When the magnetic force increases, the center LED will appear brighter.
This program makes the center LED of the micro:bit get brighter when
the magnetic force is stronger, and dimmer when it is weaker.
```blocks
led.plot(2, 2)
@ -29,4 +37,3 @@ basic.forever(() => {
### See also
[compass heading](/reference/input/compass-heading)

View File

@ -41,11 +41,7 @@ Otherwise, sometimes they would show a `0`.
### ~
### Lessons
[smiley](/lessons/smiley), [answering machine](/lessons/answering-machine), [screen wipe](/lessons/screen-wipe), [rotation animation](/lessons/rotation-animation)
### See also
[button is pressed](/reference/input/button-is-pressed), [forever](/reference/basic/forever), [random](/reference/math/math)
[button is pressed](/reference/input/button-is-pressed), [forever](/reference/basic/forever), [random](/blocks/math)

View File

@ -1,19 +1,17 @@
# On Gesture
Register an [event handler](/reference/event-handler) that will execute whenever the user executes a gesture withthe BBC micro:bit.
Start an [event handler](/reference/event-handler) (part of the
program that will run when something happens) This handler works when
you do a **gesture** (like shake, tilt, or drop the micro:bit).
```sig
input.onGesture(Gesture.Shake,() => {
})
```
## Gestures
## Example: random number
### Example: random number
The following example displays a number from 0-9 on the screen when you shake the BBC micro:bit.
This program shows a number from `0` to `9` when you shake the micro:bit.
```blocks
input.onGesture(Gesture.Shake,() => {
@ -22,24 +20,3 @@ input.onGesture(Gesture.Shake,() => {
})
```
### Example: rock, paper, scissors
The following example shows one of three images (rock, paper, or scissors) when you shake the BBC micro:bit.
```blocks
input.onGesture(Gesture.Shake,() => {
let img = images.createImage(`
. . . . . # # # # # . . . . #
. # # # . # . . . # # # . # .
. # # # . # . . . # . # # . .
. # # # . # . . . # # # . # .
. . . . . # # # # # . . . . #
`)
img.showFrame(Math.random(3))
})
```
### Lessons
[bounce image](/lessons/bounce-image), [rock paper scissors](/lessons/rock-paper-scissors)

View File

@ -1,17 +1,31 @@
# On Pin Pressed
Register an [event handler](/reference/event-handler) that will execute whenever the user holds the `GND` pin with one hand, and presses pin `0`, `1`, or `2` with the other hand, thus completing a circuit; when you run a script with this function in a web browser, click pins 0 , 1, or 2 on the simulator.
Start an [event handler](/reference/event-handler) (part of the program
that will run when something happens, like when a button is pressed).
This handler works when you press pin `0`, `1`, or `2` together with `GND`.
When you are using this function in a web browser, click the pins on the screen instead of the ones
on the BBC micro:bit.
*Note* that this function works best when the BBC micro:bit is powered by AAA battery.
If you hold the `GND` pin with one hand and touch pin `0`, `1`, or `2` with the other,
a very small (safe) amount of electricity will flow through your body and back into
the micro:bit. This is called **completing a circuit**. It's like you're a big wire!
```sig
input.onPinPressed(TouchPin.P0, () => {
})
```
## ~hint
This function works best when the BBC micro:bit is using batteries for power,
instead of the USB cable.
## ~
### Example: pin pressed counter
This example counts how many times the P0 pin is pressed. Each time the pin is pressed, the global count variable is increased by 1 and displayed on the screen.
This program counts how many times you press the `P0` pin.
Every time you press the pin, the program shows the number of times on the screen.
```blocks
let count = 0
@ -22,10 +36,6 @@ input.onPinPressed(TouchPin.P0, () => {
})
```
### Lessons
[love meter](/lessons/love-meter)
### See also
[BBC 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)

View File

@ -1,24 +1,33 @@
# Pin Is Pressed
Gets the pin state (pressed or not pressed), by detecting when the user holds the `GND` pin with one hand, and presses pin `0`, `1`, or `2` with the other hand, thus completing a circuit.
Find whether the pin you say is pressed or not pressed.
*Note* that this function works best when the BBC micro:bit is powered by AAA battery.
If you hold the `GND` pin with one hand and touch pin `0`, `1`, or `2` with the other,
a very small (safe) amount of electricity will flow through your body and back into
the micro:bit. This is called **completing a circuit**. It's like you're a big wire!
```sig
input.pinIsPressed(TouchPin.P0);
```
## ~hint
This function works best when the BBC micro:bit is using batteries for power,
instead of the USB cable.
## ~
### Parameters
* name - [String](/reference/types/string); the pin name ("P0", "P1", or "P2")
* a [string](/reference/types/string) that holds the pin name (**P0**, **P1**, or **P2**)
### returns
* [Boolean](/reference/types/boolean) - `true` if pressed, `false` if not pressed
* a [boolean](/blocks/logic/boolean) that means whether the pin you say is pressed (`true` or `false`)
### Example
This example displays 1 if P0 is pressed, and 0 if P0 is not pressed:
This program shows `1` if `P0` is pressed, and `0` if `P0` is not pressed:
```blocks
basic.forever(() => {

View File

@ -1,45 +1,58 @@
# Rotation
Get a rotation angle in degrees inferred from the accelerometer readings.
Find how much the micro:bit is tilted in different directions.
```sig
input.rotation(Rotation.Roll);
```
## ~hint
The BBC micro:bit has a part called the **accelerometer** that can
check how the micro:bit is moving.
## ~
### Parameters
* kind: [String](/reference/types/string) - one of values specifying the kind of rotation: ``pitch`` (up/down around the ``x`` axis); ``roll`` (left/right around the ``y`` axis)
* which direction you are checking: `Rotation.Pitch` (up and down) or `Rotation.Roll` (left and right)
### Returns
* [Number](/reference/types/number) - angle, in degrees.
* a [number](/reference/types/number) that means how much the microbit is tilted in the direction you say, from `0` to `360` degrees
### Example: micro:bit leveller
### Example: micro:bit leveler
The following example uses the `rotation` and the `plot leds` function to help you move the BBC micro:bit until it's level: when it is level, a smiley shows up on the screen. When running this code in a web browser, move your mouse to simulate the rotation.
This program helps you move the BBC micro:bit until it is level. When
it is level, the micro:bit shows a smiley.
```sig
If you are running this program in a browser, you can tilt the
micro:bit with your mouse.
```blocks
let pitch = 0;
basic.forever(() => {
let pitch = input.rotation(Rotation.Pitch)
let roll = input.rotation(Rotation.Roll)
pitch = input.rotation(Rotation.Pitch);
let roll = input.rotation(Rotation.Roll);
if (Math.abs(pitch) < 10 && Math.abs(roll) < 10) {
basic.plotLeds(`
. . . . .
. # . # .
. . . . .
# . . . #
. # # # .
`)
basic.showLeds(`
. # . # .
. . . . .
. . . . .
# . . . #
. # # # .
`);
} else {
basic.plotLeds(`
# . . . #
. # . # .
. . # . .
. # . # .
# . . . #
`)
}
})
basic.showLeds(`
# . . . #
. # . # .
. . # . .
. # . # .
# . . . #
`);
}
});
```
### See also

View File

@ -24,9 +24,6 @@ input.onButtonPressed(Button.B, () => {
})
```
### Lessons
[speed button](/lessons/speed-button)
### See also

View File

@ -52,8 +52,6 @@ better thermometer.
### ~
### Lessons
### See also
[compass-heading](/reference/input/compass-heading), [acceleration](/reference/input/acceleration)

View File

@ -1,6 +1,6 @@
# Brightness
Find how bright the [LED screen](/device/screen) is.
Find how bright the [LED screen](/device/screen) is _when it is turned on_.
```sig
led.brightness();
@ -8,11 +8,11 @@ led.brightness();
### Returns
* a [Number](/reference/types/number) that means how bright the screen is, from `0` (darkest) to `255` (brightest). For example, the number `127` means the screen is halfway bright.
* a [number](/reference/types/number) that means how bright the screen is when it is turned on, from `0` (darkest) to `255` (brightest). For example, the number `127` means the screen is halfway bright when it is turned on.
### Example: highest brightness
This program makes the screen completely bright if it is not that way already:
This program makes the screen completely bright when it is turned on (if it is not that way already):
```blocks
if (led.brightness() < 255) {
@ -20,6 +20,20 @@ if (led.brightness() < 255) {
}
```
### Example: change brightness
This program makes the screen brightness 100% (255). Then it turns on
the center LED (`2, 2`), waits for one second and then sets the screen
brightness to 50% (128):
```blocks
led.setBrightness(255)
led.plot(2, 2)
basic.pause(1000)
led.setBrightness(led.brightness() / 2)
```
### See also
[set brightness](/reference/led/set-brightness), [fade in](/reference/led/fade-in), [fade out](/reference/led/fade-out)

View File

@ -24,10 +24,6 @@ for (let i = 0; i < 5; i++) {
}
```
### Lessons
[glowing sword](/lessons/glowing-sword)
### See also
[brightness](/reference/led/brightness), [fade out](/reference/led/fade-out), [set brightness](/reference/led/set-brightness)

View File

@ -20,10 +20,6 @@ basic.showString("A", 1000)
led.fadeOut(1000)
```
### Lessons
[glowing sword](/lessons/glowing-sword)
### See also
[brightness](/reference/led/brightness), [fade in](/reference/led/fade-in), [set brightness](/reference/led/set-brightness)

View File

@ -6,10 +6,6 @@ Turn on all the 25 LEDs on the [LED screen](/device/screen).
led.plotAll()
```
### Lessons
[night light](/lessons/night-light)
### See also
[LED screen](/device/screen), [clear screen](/reference/basic/clear-screen)

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