pxt-calliope/docs/reference/serial/write-line.md
2016-04-15 16:36:31 -07:00

695 B

Write Line

Writes a string and a new line character (\r\n) to serial.

serial.writeLine("");

Example: streaming data

The following example constantly checks the compass heading and sends the direction to serial.

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");
    }
})

See also

serial, write value