2018-07-09 11:17:32 -07:00
|
|
|
# send Number
|
2016-03-25 16:47:20 -07:00
|
|
|
|
2017-03-16 07:57:41 -07:00
|
|
|
Broadcast a [number](/types/number) to other @boardname@s connected via ``radio``.
|
2016-07-18 14:04:15 -07:00
|
|
|
|
|
|
|
```sig
|
|
|
|
radio.sendNumber(0);
|
|
|
|
```
|
2016-03-25 16:47:20 -07:00
|
|
|
|
2017-09-07 13:42:08 -07:00
|
|
|
## Parameters
|
2016-03-25 16:47:20 -07:00
|
|
|
|
2018-07-09 11:17:32 -07:00
|
|
|
* **value**: a [number](/types/number) to send.
|
2016-03-25 16:47:20 -07:00
|
|
|
|
2016-06-09 15:30:47 -07:00
|
|
|
|
2017-09-07 13:42:08 -07:00
|
|
|
## Example: Broadcasting acceleration
|
2016-03-25 16:47:20 -07:00
|
|
|
|
2016-11-01 17:44:37 -07:00
|
|
|
This example broadcasts the value of your @boardname@'s ``acceleration``
|
|
|
|
in the `x` direction (left and right) to other @boardname@s. This kind
|
2016-07-18 14:04:15 -07:00
|
|
|
of program might be useful in a model car or model rocket.
|
2016-03-25 16:47:20 -07:00
|
|
|
|
|
|
|
```blocks
|
|
|
|
input.onButtonPressed(Button.A, () => {
|
|
|
|
radio.sendNumber(input.acceleration(Dimension.X))
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
2017-09-07 13:42:08 -07:00
|
|
|
## Light level sender
|
2016-05-27 16:22:38 -07:00
|
|
|
|
2016-05-31 17:02:22 -07:00
|
|
|
This example broadcasts the level of the light around it.
|
|
|
|
You can do some interesting things with it if you use it along with the
|
2018-07-09 11:17:32 -07:00
|
|
|
[on received number](/reference/radio/on-received-number) example.
|
2016-05-27 16:22:38 -07:00
|
|
|
|
|
|
|
```blocks
|
|
|
|
radio.setGroup(99)
|
|
|
|
basic.forever(() => {
|
|
|
|
let level = input.lightLevel()
|
|
|
|
radio.sendNumber(level)
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
2017-09-07 13:42:08 -07:00
|
|
|
## See also
|
2016-03-25 16:47:20 -07:00
|
|
|
|
2018-07-09 11:17:32 -07:00
|
|
|
[on received number](/reference/radio/on-received-number)
|
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
|
|
|
```
|