2019-12-02 05:58:26 +01:00
|
|
|
# send Value
|
2016-06-15 14:09:40 +02:00
|
|
|
|
2016-11-02 01:44:37 +01:00
|
|
|
Send a [string]() and [number]() together by ``radio`` to other @boardname@s.
|
2019-12-02 05:58:26 +01:00
|
|
|
The maximum [string]() length is 8 characters.
|
2016-06-15 14:09:40 +02:00
|
|
|
|
2016-07-18 23:04:15 +02:00
|
|
|
```sig
|
2016-10-27 23:48:22 +02:00
|
|
|
radio.sendValue("name", 0);
|
2016-07-18 23:04:15 +02:00
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## Parameters
|
2016-06-15 14:09:40 +02:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
* **name**: a [string](/types/string) that is the name of the value to send.
|
|
|
|
* **value**: a [number](/types/number) that is the value to send.
|
2016-06-15 14:09:40 +02:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## ~ hint
|
|
|
|
|
|
|
|
Watch this video to see how the radio hardware works on the @boardname@:
|
|
|
|
|
|
|
|
https://www.youtube.com/watch?v=Re3H2ISfQE8
|
|
|
|
|
|
|
|
## ~
|
|
|
|
|
|
|
|
## Example: Broadcasting acceleration
|
2016-06-15 14:09:40 +02:00
|
|
|
|
2016-11-02 01:44:37 +01:00
|
|
|
This program sends your @boardname@'s **acceleration** (amount it is
|
2016-06-17 00:15:14 +02:00
|
|
|
speeding up or slowing down) in the `x` direction (left and right) to
|
2016-11-02 01:44:37 +01:00
|
|
|
other @boardname@s. This kind of program might be useful in a model car
|
2016-06-17 00:15:14 +02:00
|
|
|
or model rocket.
|
2016-06-15 14:09:40 +02:00
|
|
|
|
|
|
|
```blocks
|
2016-06-17 00:33:35 +02:00
|
|
|
radio.setGroup(99)
|
2022-08-10 18:36:19 +02:00
|
|
|
input.onButtonEvent(Button.A, input.buttonEventClick(), () => {
|
2016-10-26 01:39:13 +02:00
|
|
|
radio.sendValue("acc", input.acceleration(Dimension.X))
|
2016-06-15 14:09:40 +02:00
|
|
|
})
|
|
|
|
```
|
|
|
|
|
2016-06-17 00:15:14 +02:00
|
|
|
This program receives the string and number sent by the last program.
|
|
|
|
Then it shows them on the LED screen.
|
|
|
|
|
|
|
|
```blocks
|
2016-06-17 00:33:35 +02:00
|
|
|
radio.setGroup(99)
|
2019-12-02 05:58:26 +01:00
|
|
|
radio.onReceivedValue(function (name, value) {
|
|
|
|
basic.showString(name);
|
|
|
|
basic.showNumber(value);
|
2016-06-17 00:15:14 +02:00
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## See also
|
2016-06-15 14:09:40 +02:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
[on received value](/reference/radio/on-received-value)
|
2016-06-15 14:09:40 +02:00
|
|
|
|
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
|
|
|
```
|