2016-07-08 20:46:51 +02:00
# Serial Write Line
2016-04-16 01:36:31 +02:00
2019-12-02 05:58:26 +01:00
Write a string to the [serial ](/device/serial ) port and start a new line of text
2016-07-08 20:46:51 +02:00
by writing `\r\n` .
2016-04-16 01:36:31 +02:00
```sig
serial.writeLine("");
```
2019-12-02 05:58:26 +01:00
## Parameters
2016-07-08 20:46:51 +02:00
2019-12-02 05:58:26 +01:00
* `text` is the [string ](/types/string ) to write to the serial port
2016-07-08 20:46:51 +02:00
2019-12-02 05:58:26 +01:00
## Examples
2016-07-08 20:46:51 +02:00
2019-12-02 05:58:26 +01:00
### Simple serial
Write the word `BOFFO` to the serial port repeatedly.
2016-07-08 20:46:51 +02:00
```blocks
basic.forever(() => {
serial.writeLine("BOFFO");
basic.pause(5000);
});
```
2019-12-02 05:58:26 +01:00
### Streaming data
2016-04-16 01:36:31 +02:00
2019-12-02 05:58:26 +01:00
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.
2016-04-16 01:36:31 +02:00
```blocks
2019-12-02 05:58:26 +01:00
let degrees = 0
let direction = ""
2016-04-16 01:36:31 +02:00
basic.forever(() => {
2019-12-02 05:58:26 +01:00
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"
2016-04-16 01:36:31 +02:00
}
2019-12-02 05:58:26 +01:00
serial.writeLine(direction + " @ " + degrees + " degrees")
basic.pause(500)
2016-04-16 01:36:31 +02:00
})
```
2019-12-02 05:58:26 +01:00
## See also
2016-04-16 01:36:31 +02:00
2016-07-08 20:46:51 +02:00
[serial ](/device/serial ),
2016-07-09 00:29:14 +02:00
[serial write number ](/reference/serial/write-number ),
2016-07-11 20:13:13 +02:00
[serial write string ](/reference/serial/write-string ),
2016-07-08 20:46:51 +02:00
[serial write value ](/reference/serial/write-value )