pxt-calliope/docs/reference/radio/send-value.md
Peli de Halleux d0a40d1ae1
tools lessons (#1218)
* tools lessons

* updated summary

* more images

* wire up images

* fixing radio send-value
2018-09-12 13:26:39 -07:00

1.0 KiB

send Value

Send a string and number together by radio to other @boardname@s. The maximum string length is 12 characters.

radio.sendValue("name", 0);

Parameters

  • name is a string to send by radio
  • value a number to send by radio

Example: Broadcasting acceleration

This program sends your @boardname@'s acceleration (amount it is speeding up or slowing down) in the x direction (left and right) to other @boardname@s. This kind of program might be useful in a model car or model rocket.

radio.setGroup(99)
input.onButtonPressed(Button.A, () => {
    radio.sendValue("acc", input.acceleration(Dimension.X))
})

This program receives the string and number sent by the last program. Then it shows them on the LED screen.

radio.setGroup(99)
radio.onReceivedValue(function (name, value) {
	basic.showString(name);
    basic.showNumber(value);
});

See also

on received value

radio