5f7a8e5301
* update yotta defaults for 16kb devices * refactor deprecated blocks * updates for button events * update button events * update refference * update docs * update docs * update button event blocks * update docs * update block id
1.5 KiB
1.5 KiB
on Received Value
Run part of a program when the @boardname@ receives a name-value-pair over radio
.
radio.onReceivedValue(function (name, value) {})
Parameters
~ hint
Watch this video to see how the radio hardware works on the @boardname@:
https://www.youtube.com/watch?v=Re3H2ISfQE8
~
Example
This program keeps sending numbers that say how fast the @boardname@ is slowing down or speeding up. When it receives numbers for the same thing from nearby @boardname@s, show the numbers as a bar graph.
radio.setGroup(1)
basic.forever(() => {
radio.sendValue("accel-x", input.acceleration(Dimension.X))
})
radio.onReceivedValue(function (name, value) {
if (name == "accel-x") {
led.plotBarGraph(value, 1023);
}
})
Troubleshooting
The ||radio:on received value||
event can only be created once, due to the hardware restrictions.
The radio set group might need to be set, synchronized , before the radio events will function.
See also
on received number, received packet, send number, send string, send value, set group
radio