2017-01-10 19:26:44 +01:00
|
|
|
# Serial Read String
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
Read the buffered serial data as a string.
|
2017-01-10 19:26:44 +01:00
|
|
|
|
|
|
|
```sig
|
|
|
|
serial.readString();
|
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## Returns
|
2017-01-10 19:26:44 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
* a [string](/types/string) containing input from the serial port. The string is empty if no data is available.
|
2017-01-10 19:26:44 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## Example
|
2017-01-10 19:26:44 +01:00
|
|
|
|
|
|
|
The following program scrolls text on the screen as it arrives from serial.
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
basic.forever(() => {
|
|
|
|
basic.showString(serial.readString());
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## See also
|
2017-01-10 19:26:44 +01:00
|
|
|
|
|
|
|
[serial](/device/serial),
|
|
|
|
[serial write line](/reference/serial/write-line),
|
|
|
|
[serial write value](/reference/serial/write-value)
|