diff --git a/docs/reference.md b/docs/reference.md index 669ddf45..dfe1acaf 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -9,8 +9,9 @@ basic.showNumber(0); input.onButtonPressed(Button.A, () => { }); -led.plot(0, 0); music.playTone(0, 0); +led.plot(0, 0); +radio.sendNumber(0); game.addScore(1); images.createImage(` . . . . . diff --git a/docs/reference/logic.md b/docs/reference/logic.md index 9a81e7ea..2ff4f982 100644 --- a/docs/reference/logic.md +++ b/docs/reference/logic.md @@ -1,39 +1,9 @@ # Logic -[if](/reference/logic/if) - -```blocks -if(true) { -} -``` - -[Boolean](/reference/types/boolean) values: *true*; *false* - -```blocks -true -false -``` - -Boolean binary operators: *and* (conjunction); *or* (disjunction) - -```blocks +```cards +if(true) {} +true; true && false; -true || false; -``` - -Boolean negation operator - -```blocks -!true -``` - -Comparison operators (=, !=, <, >, <=, >=) - -```blocks -0 == 0; -1 !- 0; -0 < 1; -1 > 0; -0 <= 1; -1 >= 0; +!true; +1 != 0; ``` diff --git a/docs/reference/logic/if.md b/docs/reference/logic/if.md index 824be5ae..48b28778 100644 --- a/docs/reference/logic/if.md +++ b/docs/reference/logic/if.md @@ -1,23 +1,26 @@ # If -Run code based on a condition. - ### @parent blocks/language Conditionally run code depending on whether a [Boolean](/reference/types/boolean) condition is true or false. -### Block Editor - -![](/static/mb/hourofcode-0.png) +```blocks +if(true) { +} +``` In the Block Editor, click on the dark blue gear icon (see above) to add an *else* or *if* to the current block. ### Example: adjusting screen brightness -![](/static/mb/blocks/game-library/pic0.png) +```blocks +if(input.lightLevel()<100){ + led.setBrightness(255); +} +``` -If the screen [brightness](/reference/led/brightness) is `< 100`, this code sets the brightness to `255`: +If the [light level](/input/light-level) is `< 100`, this code sets the brightness to `255`: ### Lessons diff --git a/docs/reference/loops.md b/docs/reference/loops.md index b55a6b2f..e436293d 100644 --- a/docs/reference/loops.md +++ b/docs/reference/loops.md @@ -1,26 +1,8 @@ # Loops -Repeat code. - - -[for](/reference/loops/for) - -```blocks +```cards for(let i = 0;i<5;i++) {} -``` - -[repeat](/reference/loops/repeat) - -![](/static/mb/blocks/contents-0.png) - -[while](/reference/loops/while) - -```blocks +for(let i = 1;i<5;i++) {} while(true) {} -``` - -[forever](/reference/basic/forever) - -```blocks basic.forever(() => {}) ``` diff --git a/docs/reference/loops/for.md b/docs/reference/loops/for.md index cc89b948..b8ebe9cd 100644 --- a/docs/reference/loops/for.md +++ b/docs/reference/loops/for.md @@ -1,15 +1,13 @@ # For -Repeat code a preset number of times. - ### @parent blocks/language - Repeat code a fixed number of times. -### Block Editor - -![](/static/mb/events-0.png) +```blocks +for(let i = 0; i < 5; ++i) { +} +``` The Block Editor *for* loop is different than the Touch Develop *for* loop in an important way. The above for loop will iterate *five* times, with the loop variable *i* taking on values 0, 1, 2, 3, and 4. The Touch Develop for loop shown below will iterate four times: diff --git a/docs/reference/loops/repeat.md b/docs/reference/loops/repeat.md index 7706e6af..a15a1893 100644 --- a/docs/reference/loops/repeat.md +++ b/docs/reference/loops/repeat.md @@ -2,8 +2,6 @@ Repeat code a preset number of times. -Repeat code a fixed number of times. - ### Block Editor ![](/static/mb/blocks/contents-0.png) diff --git a/docs/reference/loops/while.md b/docs/reference/loops/while.md index 480ad647..e3e98159 100644 --- a/docs/reference/loops/while.md +++ b/docs/reference/loops/while.md @@ -1,23 +1,14 @@ # While -Repeat code in a loop while a condition is true. - ### @parent blocks/language Repeat code while a [Boolean](/reference/types/boolean) `condition` is true. -### ~hide - +```blocks +while(true) { +} ``` -let condition = false -``` - -### ~ - -### Block Editor - -![](/static/mb/string-0.png) 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`. @@ -27,11 +18,13 @@ The condition is tested before any code runs. Which means that if the condition The following example uses a while loop to make a diagonal line on the LED screen (points `0, 0`, `1, 1`, `2, 2`, `3, 3`, `4, 4`). -// index is set to 4 - -![](/static/mb/blocks/var-10.png) - -// subtract 1 from `index` each time through loop +```blocks +let index = 4; +while(index >= 0) { + led.plot(index, index); + index--; +} +``` ### Lessons diff --git a/docs/reference/radio.md b/docs/reference/radio.md index 27f23b08..36150d2c 100644 --- a/docs/reference/radio.md +++ b/docs/reference/radio.md @@ -16,5 +16,5 @@ radio.receivedSignalStrength(); radio.setGroup(0); radio.setTransmitPower(0); radio.writeValueToSerial(); -radio.setTransmitSerialNumber(◊); +radio.setTransmitSerialNumber(true); ``` diff --git a/docs/reference/serial.md b/docs/reference/serial.md index e4a373d0..bf72fd14 100644 --- a/docs/reference/serial.md +++ b/docs/reference/serial.md @@ -3,6 +3,9 @@ Reading and writing data over a serial connection. ```cards -serial.writeValue(x, 0); serial.writeLine(""); +serial.writeNumber(0); +serial.writeValue(x, 0); +serial.writeString(""); +serial.readLine(); ``` diff --git a/libs/microbit-radio/_locales/microbit-radio-strings.json b/libs/microbit-radio/_locales/microbit-radio-strings.json index 11c6bc47..9c61d0d4 100644 --- a/libs/microbit-radio/_locales/microbit-radio-strings.json +++ b/libs/microbit-radio/_locales/microbit-radio-strings.json @@ -93,6 +93,9 @@ "radio.setTransmitSerialNumber": "Set the radio to transmit the serial number in each message.", "radio.writeValueToSerial": "Reads a value sent with `stream value` and writes it\nto the serial stream as JSON", "serial": "Reading and writing data over a serial connection.", + "serial.readLine": "Reads a line of text from the serial port.", "serial.writeLine": "Prints a line of text to the serial", + "serial.writeNumber": "Prints a numeric value to the serial", + "serial.writeString": "Sends a piece of text through Serial connection.", "serial.writeValue": "Writes a ``name: value`` pair line to the serial." } \ No newline at end of file