Skip to content

Latest commit

 

History

History
45 lines (32 loc) · 977 Bytes

on-data-received.md

File metadata and controls

45 lines (32 loc) · 977 Bytes

on Data Received

Run part of a program when the @boardname@ receives a number or string over radio.

radio.onDataReceived(() => { });

~ hint

Deprecated

This API has been deprecated! Use on received number instead.

~

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.

basic.forever(() => {
    radio.sendNumber(input.acceleration(Dimension.X));
})
radio.onDataReceived(() => {
    led.plotBarGraph(radio.receiveNumber(), 1023);
})

See also

on received number, send number, set group

radio