pxt-calliope/docs/reference/serial/write-value.md
2016-04-15 16:40:51 -07:00

740 B

Write Value

Writes name/value pair and a new line character (\r\n) to serial.

serial.writeValue("x", 0);

Example: streaming data

The sample below sends the temperature and light level every 10 seconds.

basic.forever(() => {
    serial.writeValue("temp", input.temperature())
    serial.writeValue("light", input.lightLevel())
    basic.pause(10000);
})

Plot bar graph does serial!

If you use the led.plotBarGraph function, it automatically writes the value to the serial as well.

basic.forever(() => {
    led.plotBarGraph(input.lightLevel(), 255)
    basic.pause(10000);
})

See also

serial, write line