On Data Packet Received

Run part of a program when the Calliope mini receives a number or string over radio.

radio.onDataPacketReceived(({receivedNumber, receivedString, time, serial, signal}) => { });

To add or remove the parts of the packet from the block, try clicking the blue gear in the corner!

Callback Parameters

Example

This program keeps sending numbers that says how fast the Calliope mini is slowing down or speeding up. It also receives numbers for the same thing from nearby Calliope minis. It shows these numbers as a bar graph.

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

See also

send number, send string, send value, set group

radio

Edit this page on GitHub