@ -7,11 +7,11 @@ Registers an event to be fired when one of the delimiter is matched.
|
||||
serial.onDataReceived(",", () => {})
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* `delimiters` is a [string](/types/string) containing any of the character to match
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
Read values separated by `,`:
|
||||
|
||||
@ -21,7 +21,7 @@ serial.onDataReceived(serial.delimiters(Delimiters.Comma), () => {
|
||||
})
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[serial](/device/serial),
|
||||
[serial write line](/reference/serial/write-line),
|
||||
|
@ -6,7 +6,7 @@ Read the buffered serial data as a buffer
|
||||
serial.readBuffer(64);
|
||||
```
|
||||
|
||||
### Returns
|
||||
## Returns
|
||||
|
||||
* a Buffer containing input from the serial port. Empty if no data available.
|
||||
|
||||
|
@ -6,19 +6,19 @@ Read a line of text from the serial port.
|
||||
serial.readLine();
|
||||
```
|
||||
|
||||
#### ~hint
|
||||
### ~hint
|
||||
|
||||
This function expects the line it reads to be terminated with the `\r`
|
||||
character. If your terminal software does not terminate lines with
|
||||
`\r`, this function will probably never return a value.
|
||||
|
||||
#### ~
|
||||
### ~
|
||||
|
||||
### Returns
|
||||
## Returns
|
||||
|
||||
* a [string](/types/string) containing input from the serial port, such as a response typed by a user
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
The following example requests the user's name, then repeats it to greet the user.
|
||||
|
||||
@ -31,7 +31,7 @@ basic.forever(() => {
|
||||
});
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[serial](/device/serial),
|
||||
[serial write line](/reference/serial/write-line),
|
||||
|
@ -6,11 +6,11 @@ Read the buffered serial data as a string
|
||||
serial.readString();
|
||||
```
|
||||
|
||||
### Returns
|
||||
## Returns
|
||||
|
||||
* a [string](/types/string) containing input from the serial port. Empty if no data available.
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
The following program scrolls text on the screen as it arrives from serial.
|
||||
|
||||
@ -20,7 +20,7 @@ basic.forever(() => {
|
||||
});
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[serial](/device/serial),
|
||||
[serial write line](/reference/serial/write-line),
|
||||
|
@ -6,11 +6,11 @@ Read a text from the serial port until a delimiter is found.
|
||||
serial.readUntil(",");
|
||||
```
|
||||
|
||||
### Returns
|
||||
## Returns
|
||||
|
||||
* a [string](/types/string) containing input from the serial port, such as a response typed by a user
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
The following example reads strings separated by commands (``,``).
|
||||
|
||||
@ -21,7 +21,7 @@ basic.forever(() => {
|
||||
});
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[serial](/device/serial),
|
||||
[serial write line](/reference/serial/write-line),
|
||||
|
@ -7,13 +7,13 @@ Dynamically configure the serial instance to use pins other than
|
||||
serial.redirect(SerialPin.P0, SerialPin.P0, BaudRate.BaudRate115200);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* ``tx``: the [serial pin](/device/pins) on which to transmit data
|
||||
* ``rx``: the [serial pin](/device/pins) on which to receive data
|
||||
* ``rate``: the baud rate at which to transmit and receive data (either `9600` or ``115200``)
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
When button ``A`` is pressed, the following example reconfigures the
|
||||
serial instance. The new configuration uses pin ``P1`` to transmit and
|
||||
@ -25,7 +25,7 @@ input.onButtonPressed(Button.A, () => {
|
||||
});
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[serial](/device/serial)
|
||||
|
||||
|
@ -6,6 +6,6 @@ Write a buffer to the [serial](/device/serial) port.
|
||||
serial.writeBuffer(pins.createBuffer(0));
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* `buffer` is the buffer to write to the serial port
|
||||
|
@ -7,11 +7,11 @@ by writing `\r\n`.
|
||||
serial.writeLine("");
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* `text` is the [string](/types/string) to write to the serial port
|
||||
|
||||
### Example: simple serial
|
||||
## Example: simple serial
|
||||
|
||||
This program writes the word `BOFFO` to the serial port repeatedly.
|
||||
|
||||
@ -22,7 +22,7 @@ basic.forever(() => {
|
||||
});
|
||||
```
|
||||
|
||||
### Example: streaming data
|
||||
## Example: streaming data
|
||||
|
||||
This program checks the
|
||||
[compass heading](/reference/input/compass-heading) and sends the
|
||||
@ -44,7 +44,7 @@ basic.forever(() => {
|
||||
}
|
||||
})
|
||||
```
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[serial](/device/serial),
|
||||
[serial write number](/reference/serial/write-number),
|
||||
|
@ -6,11 +6,11 @@ Write a number to the [serial](/device/serial) port.
|
||||
serial.writeNumber(0);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* `value` is the [number](/types/number) to write to the serial port
|
||||
|
||||
### Example: one through ten
|
||||
## Example: one through ten
|
||||
|
||||
This program repeatedly writes a 10-digit number to the serial port.
|
||||
|
||||
@ -21,7 +21,7 @@ basic.forever(() => {
|
||||
});
|
||||
```
|
||||
|
||||
### Example: plot bar graph does serial
|
||||
## Example: plot bar graph does serial
|
||||
|
||||
If you use the ``led.plotBarGraph`` function, it writes the number
|
||||
being plotted to the serial port too.
|
||||
@ -33,7 +33,7 @@ basic.forever(() => {
|
||||
})
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[serial](/device/serial),
|
||||
[serial write line](/reference/serial/write-line),
|
||||
|
@ -7,11 +7,11 @@ without starting a new line afterward.
|
||||
serial.writeString("");
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* `text` is the [string](/types/string) to write to the serial port
|
||||
|
||||
### Example: simple serial
|
||||
## Example: simple serial
|
||||
|
||||
This program writes the word `JUMBO` to the serial port repeatedly,
|
||||
without any new lines.
|
||||
@ -23,7 +23,7 @@ basic.forever(() => {
|
||||
});
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[serial](/device/serial),
|
||||
[serial write line](/reference/serial/write-line),
|
||||
|
@ -6,7 +6,7 @@ Write a name/value pair and a newline character (`\r\n`) to the [serial](/device
|
||||
serial.writeValue("x", 0);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* `name` is the [string](/types/string) to write to the serial port
|
||||
* `value` is the [number](/types/number) to write to the serial port
|
||||
@ -14,7 +14,7 @@ serial.writeValue("x", 0);
|
||||
|
||||
|
||||
|
||||
### Example: streaming data
|
||||
## Example: streaming data
|
||||
|
||||
Every 10 seconds, the example below sends the temperature and light level
|
||||
to the serial port.
|
||||
@ -27,15 +27,15 @@ basic.forever(() => {
|
||||
})
|
||||
```
|
||||
|
||||
#### ~hint
|
||||
### ~hint
|
||||
|
||||
The [send value](/reference/radio/send-value) function broadcasts
|
||||
string/number pairs. You can use a second @boardname@ to receive them,
|
||||
and then send them directly to the serial port with ``write value``.
|
||||
|
||||
#### ~
|
||||
### ~
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[serial](/device/serial),
|
||||
[serial write line](/reference/serial/write-line),
|
||||
|
Reference in New Issue
Block a user