2.1.28, initiation update to PXT v5.28.24 (#54)

This commit is contained in:
Amerlander
2019-12-02 05:58:26 +01:00
committed by Peli de Halleux
parent 38a964516e
commit 5c114a0c57
1261 changed files with 50692 additions and 21604 deletions

View File

@ -1,19 +1,21 @@
# Serial Write Line
Write a string to the [serial](/device/serial) port and start a new line of text
Write a string to the [serial](/device/serial) port and start a new line of text
by writing `\r\n`.
```sig
serial.writeLine("");
```
### Parameters
## Parameters
* `text` is the [string](/reference/types/string) to write to the serial port
* `text` is the [string](/types/string) to write to the serial port
### Example: simple serial
## Examples
This program writes the word `BOFFO` to the serial port repeatedly.
### Simple serial
Write the word `BOFFO` to the serial port repeatedly.
```blocks
basic.forever(() => {
@ -22,29 +24,37 @@ basic.forever(() => {
});
```
### Example: streaming data
### Streaming data
This program checks the
[compass heading](/reference/input/compass-heading) and sends the
direction to the serial port repeatedly.
Check the [compass heading](/reference/input/compass-heading) and show the direction on the screen. Also, send both the direction and degree heading to the serial port.
```blocks
let degrees = 0
let direction = ""
basic.forever(() => {
let heading = input.compassHeading()
if (heading < 45) {
serial.writeLine("N");
} else if (heading < 135) {
serial.writeLine("E");
}
else if (heading < 225) {
serial.writeLine("S");
}
else {
serial.writeLine("W");
degrees = input.compassHeading()
if (degrees < 45) {
basic.showArrow(ArrowNames.North)
direction = "North"
} else if (degrees < 135) {
basic.showArrow(ArrowNames.East)
direction = "East"
} else if (degrees < 225) {
basic.showArrow(ArrowNames.South)
direction = "South"
} else if (degrees < 315) {
basic.showArrow(ArrowNames.West)
direction = "West"
} else {
basic.showArrow(ArrowNames.North)
direction = "North"
}
serial.writeLine(direction + " @ " + degrees + " degrees")
basic.pause(500)
})
```
### See also
## See also
[serial](/device/serial),
[serial write number](/reference/serial/write-number),