set Group

Set the group ID for sending and receiving messages over radio.

radio.setGroup(0)

A group is like a cable channel (a micro:bit can only send or receive date in one group at a time) and the group ID is like the channel number.

If you load the same program onto two different micro:bits, they will be able to talk to each other because they will have the same group ID.

Parameters

  • id: a radio group ID number from 0 to 255.

Default radio group

If you haven’t set a radio group for the micro:bit, it will use the default group number of 0.

Simulator

This function only works on the micro:bit, not in browsers.

Example

Set a radio group to send and receive a number between micro:bits.

radio.setGroup(1)
radio.onReceivedNumber(function (receivedNumber) {
    basic.showNumber(0)
    basic.clearScreen()
})
input.onButtonPressed(Button.A, function () {
    radio.sendNumber(0)
})

See also

on received number, on received string, on received value, send number, send value, send string

radio