2019-12-02 05:58:26 +01:00
|
|
|
# send String
|
2016-05-25 01:53:13 +01:00
|
|
|
|
2016-11-01 17:44:37 -07:00
|
|
|
Sends a string to other @boardname@s in the area connected by radio. The
|
2016-10-24 16:30:21 -07:00
|
|
|
maximum string length is 19 characters.
|
2016-05-25 01:53:13 +01:00
|
|
|
|
|
|
|
```sig
|
2019-12-02 05:58:26 +01:00
|
|
|
radio.sendString("hi!")
|
2016-05-25 01:53:13 +01:00
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## Parameters
|
2016-05-25 01:53:13 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
* **msg**: a [string](/types/string) to send by radio.
|
2016-05-25 01:53:13 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## ~ hint
|
2016-06-09 15:30:47 -07:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
Watch this video to see how the radio hardware works on the @boardname@:
|
|
|
|
|
|
|
|
https://www.youtube.com/watch?v=Re3H2ISfQE8
|
|
|
|
|
|
|
|
## ~
|
|
|
|
|
|
|
|
## Example: Two-way radio
|
2016-05-25 01:53:13 +01:00
|
|
|
|
2016-11-01 17:44:37 -07:00
|
|
|
If you load this program onto two or more @boardname@s, you can send a
|
2016-07-18 14:04:15 -07:00
|
|
|
code word from one of them to the others by pressing button `A`. The
|
2016-11-01 17:44:37 -07:00
|
|
|
other @boardname@s will receive the code word and then show it.
|
2016-05-25 01:53:13 +01:00
|
|
|
|
|
|
|
```blocks
|
|
|
|
input.onButtonPressed(Button.A, () => {
|
2016-05-27 12:03:54 -07:00
|
|
|
radio.sendString("Codeword: TRIMARAN")
|
|
|
|
basic.showString("SENT");
|
2016-05-25 01:53:13 +01:00
|
|
|
})
|
2019-12-02 05:58:26 +01:00
|
|
|
radio.onReceivedString(function (receivedString) {
|
2016-10-25 16:39:13 -07:00
|
|
|
basic.showString(receivedString);
|
2019-12-02 05:58:26 +01:00
|
|
|
})
|
2016-05-25 01:53:13 +01:00
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## ~hint
|
2016-05-27 12:03:54 -07:00
|
|
|
|
|
|
|
A radio that can both transmit and receive is called a _transceiver_.
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## ~
|
2016-05-27 12:03:54 -07:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## See also
|
2016-05-25 01:53:13 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
[on received string](/reference/radio/on-received-string)
|
2016-08-09 16:28:08 +01:00
|
|
|
|
|
|
|
```package
|
2016-10-22 21:29:31 -07:00
|
|
|
radio
|
2016-08-09 16:28:08 +01:00
|
|
|
```
|