Rewrote one Serial topic; shifted some material
This commit is contained in:
parent
af91622dda
commit
8751d2aaa1
@ -11,7 +11,7 @@ serial.writeLine("");
|
|||||||
|
|
||||||
* `line` is the [string](/reference/types/string) to write to the serial port
|
* `line` is the [string](/reference/types/string) to write to the serial port
|
||||||
|
|
||||||
### Example
|
### Example: simple serial
|
||||||
|
|
||||||
This program writes the word `BOFFO` to the serial port repeatedly.
|
This program writes the word `BOFFO` to the serial port repeatedly.
|
||||||
|
|
||||||
@ -47,4 +47,5 @@ basic.forever(() => {
|
|||||||
### See also
|
### See also
|
||||||
|
|
||||||
[serial](/device/serial),
|
[serial](/device/serial),
|
||||||
|
[serial write number](/reference/serial/write-number),
|
||||||
[serial write value](/reference/serial/write-value)
|
[serial write value](/reference/serial/write-value)
|
||||||
|
@ -10,7 +10,7 @@ serial.writeNumber(0);
|
|||||||
|
|
||||||
* `number` is the [number](/reference/types/number) to write to the serial port
|
* `number` is the [number](/reference/types/number) to write to the serial port
|
||||||
|
|
||||||
### Example
|
### Example: one through ten
|
||||||
|
|
||||||
This program repeatedly writes a 10-digit number to the serial port.
|
This program repeatedly writes a 10-digit number to the serial port.
|
||||||
|
|
||||||
@ -21,8 +21,21 @@ basic.forever(() => {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Example: plot bar graph does serial
|
||||||
|
|
||||||
|
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);
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
### See also
|
### See also
|
||||||
|
|
||||||
[serial](/device/serial),
|
[serial](/device/serial),
|
||||||
[serial write value](/reference/serial/write-value),
|
[serial write line](/reference/serial/write-line),
|
||||||
[serial write line](/reference/serial/write-line)
|
[serial write value](/reference/serial/write-value)
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Write Value
|
# Write Value
|
||||||
|
|
||||||
Writes name/value pair and a new line character (`\r\n`) to [serial](/device/serial).
|
Write a name/value pair and a newline character (`\r\n`) to the [serial](/device/serial) port.
|
||||||
|
|
||||||
```sig
|
```sig
|
||||||
serial.writeValue("x", 0);
|
serial.writeValue("x", 0);
|
||||||
@ -8,7 +8,8 @@ serial.writeValue("x", 0);
|
|||||||
|
|
||||||
### Example: streaming data
|
### Example: streaming data
|
||||||
|
|
||||||
The sample below sends the temperature and light level every 10 seconds.
|
Every 10 seconds, the example below sends the temperature and light level
|
||||||
|
to the serial port.
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
basic.forever(() => {
|
basic.forever(() => {
|
||||||
@ -18,19 +19,17 @@ basic.forever(() => {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Plot bar graph does serial!
|
#### ~hint
|
||||||
|
|
||||||
If you use the `led.plotBarGraph` function, it automatically writes the value to the serial as well.
|
The [send value](/reference/radio/send-value) function broadcasts
|
||||||
|
string/number pairs. You can use a second micro:bit to receive them,
|
||||||
```blocks
|
and then send them directly to the serial port with ``write value``.
|
||||||
basic.forever(() => {
|
|
||||||
led.plotBarGraph(input.lightLevel(), 255)
|
|
||||||
basic.pause(10000);
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
|
#### ~
|
||||||
|
|
||||||
### See also
|
### See also
|
||||||
|
|
||||||
[serial](/device/serial), [write line](/reference/serial/write-line)
|
[serial](/device/serial),
|
||||||
|
[serial write line](/reference/serial/write-line),
|
||||||
|
[serial write number](/reference/serial/write-number),
|
||||||
|
[send value](/reference/radio/send-value)
|
||||||
|
Loading…
Reference in New Issue
Block a user