2016-07-08 20:46:51 +02:00
# Serial Write Line
2016-04-16 01:36:31 +02:00
2018-12-17 22:27:24 +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("");
```
2017-09-07 22:42:08 +02:00
## Parameters
2016-07-08 20:46:51 +02:00
2017-03-16 15:57:41 +01:00
* `text` is the [string ](/types/string ) to write to the serial port
2016-07-08 20:46:51 +02:00
2018-12-17 22:27:24 +01:00
## Examples
2016-07-08 20:46:51 +02:00
2018-12-17 22:27:24 +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);
});
```
2018-12-17 22:27:24 +01:00
### Streaming data
2016-04-16 01:36:31 +02:00
2018-12-17 22:27:24 +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
2017-09-11 13:22:10 +02:00
let degrees = 0
2018-12-17 22:27:24 +01:00
let direction = ""
2016-04-16 01:36:31 +02:00
basic.forever(() => {
2017-09-11 13:22:10 +02:00
degrees = input.compassHeading()
if (degrees < 45 ) {
basic.showArrow(ArrowNames.North)
2018-12-17 22:27:24 +01:00
direction = "North"
2017-09-11 13:22:10 +02:00
} else if (degrees < 135 ) {
2018-03-28 00:02:38 +02:00
basic.showArrow(ArrowNames.East)
2018-12-17 22:27:24 +01:00
direction = "East"
2017-09-11 13:22:10 +02:00
} else if (degrees < 225 ) {
basic.showArrow(ArrowNames.South)
2018-12-17 22:27:24 +01:00
direction = "South"
2017-09-11 13:22:10 +02:00
} else if (degrees < 315 ) {
2018-03-28 00:02:38 +02:00
basic.showArrow(ArrowNames.West)
2018-12-17 22:27:24 +01:00
direction = "West"
2017-09-11 13:22:10 +02:00
} else {
basic.showArrow(ArrowNames.North)
2018-12-17 22:27:24 +01:00
direction = "North"
2016-04-16 01:36:31 +02:00
}
2018-12-17 22:27:24 +01:00
serial.writeLine(direction + " @ " + degrees + " degrees")
basic.pause(500)
2016-04-16 01:36:31 +02:00
})
```
2018-12-17 22:27:24 +01:00
2017-09-07 22:42:08 +02: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 )