2016-07-08 21:45:31 +02:00
|
|
|
# Serial Write Number
|
|
|
|
|
|
|
|
Write a number to the [serial](/device/serial) port.
|
|
|
|
|
|
|
|
```sig
|
|
|
|
serial.writeNumber(0);
|
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## Parameters
|
2016-07-08 21:45:31 +02:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
* `value` is the [number](/types/number) to write to the serial port
|
2016-07-08 21:45:31 +02:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## Example: one two three
|
2016-07-08 21:45:31 +02:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
This program repeatedly writes a 3-digit number to the serial port.
|
2016-07-08 21:45:31 +02:00
|
|
|
|
|
|
|
```blocks
|
|
|
|
basic.forever(() => {
|
2019-12-02 05:58:26 +01:00
|
|
|
serial.writeNumber(123);
|
2016-07-08 21:45:31 +02:00
|
|
|
basic.pause(5000);
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## Example: plot bar graph does serial
|
2016-07-09 00:29:14 +02:00
|
|
|
|
|
|
|
If you use the ``led.plotBarGraph`` function, it writes the number
|
|
|
|
being plotted to the serial port too.
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
basic.forever(() => {
|
|
|
|
led.plotBarGraph(input.lightLevel(), 255)
|
|
|
|
basic.pause(10000);
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## See also
|
2016-07-08 21:45:31 +02:00
|
|
|
|
|
|
|
[serial](/device/serial),
|
2016-07-09 00:29:14 +02:00
|
|
|
[serial write line](/reference/serial/write-line),
|
2019-12-02 05:58:26 +01:00
|
|
|
[serial write value](/reference/serial/write-value),
|
|
|
|
[serial write numbers](/reference/serial/write-numbers)
|
2016-07-09 00:29:14 +02:00
|
|
|
|