2016-05-25 02:53:13 +02:00
|
|
|
# Send String
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-27 21:03:54 +02:00
|
|
|
Sends a string to other micro:bits in the area connected by radio.
|
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
|
|
|
|
|
2016-05-27 21:03:54 +02:00
|
|
|
* `text` is a [String](/reference/types/string) to send by radio.
|
2016-05-25 02:53:13 +02:00
|
|
|
|
2016-05-27 21:03:54 +02:00
|
|
|
### Example: Two-way radio
|
2016-05-25 02:53:13 +02:00
|
|
|
|
2016-05-27 21:03:54 +02:00
|
|
|
If you load this program onto two or more micro:bits, you can send a code word from one of them to the others by pressing button `A`.
|
|
|
|
The other micro:bits 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
|
|
|
|
|
|
|
radio.onDataReceived(() => {
|
|
|
|
basic.showString(radio.receiveString());
|
|
|
|
});
|
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
|
|
|
|
|
|
|
|
[receive string](/reference/radio/receive-string), [on data received](/reference/radio/on-data-received)
|