2016-03-26 00:47:20 +01:00
|
|
|
# Send Number
|
|
|
|
|
2016-06-01 02:02:22 +02:00
|
|
|
Broadcast a number to other micro:bits connected via ``radio``.
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
### Parameters
|
|
|
|
|
2016-06-01 02:02:22 +02:00
|
|
|
* num - a number to send.
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2016-06-01 02:02:22 +02:00
|
|
|
### Example: Broadcasting acceleration
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2016-06-01 02:02:22 +02:00
|
|
|
This example broadcasts the value of your micro:bit's ``acceleration`` in the `x` direction
|
|
|
|
(left and right) to other micro:bits.
|
|
|
|
This kind of program might be useful in a model car or model rocket.
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
```blocks
|
|
|
|
input.onButtonPressed(Button.A, () => {
|
|
|
|
radio.sendNumber(input.acceleration(Dimension.X))
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
2016-05-28 01:22:38 +02:00
|
|
|
### Light level sender
|
|
|
|
|
2016-06-01 02:02:22 +02: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
|
|
|
|
[Mailbot](/reference/radio/receive-number) example.
|
2016-05-28 01:22:38 +02:00
|
|
|
|
|
|
|
```blocks
|
|
|
|
radio.setGroup(99)
|
|
|
|
basic.forever(() => {
|
|
|
|
let level = input.lightLevel()
|
|
|
|
radio.sendNumber(level)
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
2016-03-26 00:47:20 +01:00
|
|
|
### See also
|
|
|
|
|
2016-04-16 00:02:26 +02:00
|
|
|
[receive number](/reference/radio/receive-number), [on data received](/reference/radio/on-data-received)
|
2016-03-26 00:47:20 +01:00
|
|
|
|