pxt-calliope/docs/reference/radio/on-data-received.md
Peli de Halleux 2b504d863d
Radiodocsupdate (#1430)
* a few updates

* more updates

* reorder radio blocks

* more shuffling of new radio apis

* fixing hot or ocold

* more doc fixes

* more updates

* fixing docs issues

* more doc fixes

* restore docs errors

* missing packate

* renamed argument of callback

* mssing radio

* more odcs fixes

* lock turtle

* ignore docs for now
2018-10-15 15:32:09 -07:00

36 lines
912 B
Markdown

# On Data Received
> Note: This API has been deprecated! Use [on received number](/reference/radio/on-received-number) instead.
Run part of a program when the @boardname@ receives a
[number](/types/number) or [string](/types/string) over ``radio``.
```sig
radio.onDataReceived(() => { });
```
## Example
This program keeps sending numbers that says how fast the @boardname@ is
slowing down or speeding up. It also receives numbers for the same
thing from nearby @boardname@s. It shows these numbers as a
[bar graph](/reference/led/plot-bar-graph).
```blocks
basic.forever(() => {
radio.sendNumber(input.acceleration(Dimension.X));
})
radio.onDataReceived(() => {
led.plotBarGraph(radio.receiveNumber(), 1023);
})
```
## See also
[on received number](/reference/radio/on-received-number),
[send number](/reference/radio/send-number), [set group](/reference/radio/set-group)
```package
radio
```