2019-12-02 05:58:26 +01:00
|
|
|
# on Data Received
|
2016-10-25 01:30:21 +02:00
|
|
|
|
2016-11-02 01:44:37 +01:00
|
|
|
Run part of a program when the @boardname@ receives a
|
2019-12-02 05:58:26 +01:00
|
|
|
[number](/types/number) or [string](/types/string) over radio.
|
|
|
|
|
|
|
|
```sig
|
|
|
|
radio.onDataReceived(() => { });
|
|
|
|
```
|
|
|
|
|
|
|
|
## ~ hint
|
|
|
|
|
|
|
|
**Deprecated**
|
|
|
|
|
|
|
|
This API has been deprecated! Use [on received number](/reference/radio/on-received-number) instead.
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## ~
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2016-07-18 23:04:15 +02:00
|
|
|
```sig
|
|
|
|
radio.onDataReceived(() => { });
|
|
|
|
```
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## Example
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2016-11-02 01:44:37 +01:00
|
|
|
This program keeps sending numbers that says how fast the @boardname@ is
|
2016-06-03 01:24:06 +02:00
|
|
|
slowing down or speeding up. It also receives numbers for the same
|
2016-11-02 01:44:37 +01:00
|
|
|
thing from nearby @boardname@s. It shows these numbers as a
|
2016-06-03 01:24:06 +02:00
|
|
|
[bar graph](/reference/led/plot-bar-graph).
|
2016-06-02 21:52:03 +02:00
|
|
|
|
2016-03-26 00:47:20 +01:00
|
|
|
```blocks
|
|
|
|
basic.forever(() => {
|
|
|
|
radio.sendNumber(input.acceleration(Dimension.X));
|
|
|
|
})
|
|
|
|
radio.onDataReceived(() => {
|
|
|
|
led.plotBarGraph(radio.receiveNumber(), 1023);
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## See also
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
[on received number](/reference/radio/on-received-number),
|
2016-06-02 21:52:03 +02:00
|
|
|
[send number](/reference/radio/send-number), [set group](/reference/radio/set-group)
|
2016-03-26 00:47:20 +01: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
|
|
|
```
|