pxt-calliope/docs/reference/radio/set-group.md

46 lines
1.1 KiB
Markdown
Raw Normal View History

# set Group
2016-03-26 00:47:20 +01:00
2016-06-02 02:11:28 +02:00
Make a program have the group ID you tell it for sending and receiving
with radio.
```sig
radio.setGroup(0);
```
A group is like a cable channel (a @boardname@ can only
2016-06-02 02:11:28 +02:00
send or receive in one group at a time). A group ID is like the cable
channel number.
2016-03-26 00:47:20 +01:00
2016-06-02 02:11:28 +02:00
If you do not tell your program which group ID to use with this
function, it will figure out its own group ID by itself. If you load
2016-11-02 01:44:37 +01:00
the very same program onto two different @boardname@s, they will be able
2016-06-02 02:11:28 +02:00
to talk to each other because they will have the same group ID.
2016-03-26 00:47:20 +01:00
## Parameters
2016-03-26 00:47:20 +01:00
* **id**: a [number](/types/number) from ``0`` to ``255``.
2016-03-26 00:47:20 +01:00
## Simulator
2016-06-10 00:30:47 +02:00
2016-11-02 01:44:37 +01:00
This function only works on the @boardname@, not in browsers.
2016-06-10 00:30:47 +02:00
## Example
2016-03-26 00:47:20 +01:00
2016-06-02 02:11:28 +02:00
This program makes the group ID equal 128.
2016-03-26 00:47:20 +01:00
```blocks
radio.setGroup(128)
```
## See also
2016-03-26 00:47:20 +01:00
[on received number](/reference/radio/on-received-number),
[on received string](/reference/radio/on-received-string),
[on received value](/reference/radio/on-received-value),
[send number](/reference/radio/send-number),
[send value](/reference/radio/send-value),
[send string](/reference/radio/send-string)
2016-03-26 00:47:20 +01:00
```package
radio
```