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