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