Write a string to the serial port and start a new line of text
by writing \r\n
.
serial.writeLine("");
text
is the string to write to the serial portThis program writes the word BOFFO
to the serial port repeatedly.
basic.forever(() => {
serial.writeLine("BOFFO");
basic.pause(5000);
});
This program checks the compass heading and sends the direction to the serial port repeatedly.
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");
}
})
serial, serial write number, serial write string, serial write value