2016-06-16 15:15:14 -07:00
|
|
|
# Send Value
|
2016-06-15 08:09:40 -04:00
|
|
|
|
2016-11-01 17:44:37 -07:00
|
|
|
Send a [string]() and [number]() together by ``radio`` to other @boardname@s.
|
2016-10-24 16:30:21 -07:00
|
|
|
The maximum [string]() length is 12 characters.
|
2016-06-15 08:09:40 -04:00
|
|
|
|
2016-07-18 14:04:15 -07:00
|
|
|
```sig
|
2016-10-27 14:48:22 -07:00
|
|
|
radio.sendValue("name", 0);
|
2016-07-18 14:04:15 -07:00
|
|
|
```
|
|
|
|
|
2016-06-15 08:09:40 -04:00
|
|
|
### Parameters
|
|
|
|
|
2016-07-18 14:04:15 -07:00
|
|
|
* ``name`` is a [string](/reference/types/string) to send by radio
|
|
|
|
* ``value`` a [number](/reference/types/number) to send by radio
|
2016-06-15 08:09:40 -04:00
|
|
|
|
|
|
|
### Example: Broadcasting acceleration
|
|
|
|
|
2016-11-01 17:44:37 -07:00
|
|
|
This program sends your @boardname@'s **acceleration** (amount it is
|
2016-06-16 15:15:14 -07:00
|
|
|
speeding up or slowing down) in the `x` direction (left and right) to
|
2016-11-01 17:44:37 -07:00
|
|
|
other @boardname@s. This kind of program might be useful in a model car
|
2016-06-16 15:15:14 -07:00
|
|
|
or model rocket.
|
2016-06-15 08:09:40 -04:00
|
|
|
|
|
|
|
```blocks
|
2016-06-16 15:33:35 -07:00
|
|
|
radio.setGroup(99)
|
2016-06-15 08:09:40 -04:00
|
|
|
input.onButtonPressed(Button.A, () => {
|
2016-10-25 16:39:13 -07:00
|
|
|
radio.sendValue("acc", input.acceleration(Dimension.X))
|
2016-06-15 08:09:40 -04:00
|
|
|
})
|
|
|
|
```
|
|
|
|
|
2016-06-16 15:15:14 -07:00
|
|
|
This program receives the string and number sent by the last program.
|
|
|
|
Then it shows them on the LED screen.
|
|
|
|
|
|
|
|
```blocks
|
2016-06-16 15:33:35 -07:00
|
|
|
radio.setGroup(99)
|
2016-10-25 16:39:13 -07:00
|
|
|
radio.onDataPacketReceived(({ receivedString, receivedNumber }) => {
|
|
|
|
basic.showString(receivedString);
|
2016-10-24 16:30:21 -07:00
|
|
|
basic.showNumber(receivedNumber);
|
2016-06-16 15:15:14 -07:00
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2016-06-15 08:09:40 -04:00
|
|
|
### See also
|
|
|
|
|
2016-10-24 16:30:21 -07:00
|
|
|
[on data packet received](/reference/radio/on-data-packet-received)
|
2016-06-15 08:09:40 -04:00
|
|
|
|
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
|
|
|
```
|