1001 B
1001 B
On Data Packet Received
Run part of a program when the micro:bit receives a
number or string over radio
.
radio.onDataPacketReceived((packet: Packet) => { });
Callback Parameters
packet
- the packet that was received by the radio
Example
This program keeps sending numbers that says how fast the micro:bit is slowing down or speeding up. It also receives numbers for the same thing from nearby micro:bits. 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