You have to import the radio library, pick a channel number and ensure the radio is turned on. All microbits you want yours to communicate with must be on the same channel (between 0 and 100).
import radio radio.config(channel=10) radio.on()
# If there is a message, it will be put into the variable received. # - Will be set to `None` if there isn't a message. received = radio.receive() display.scroll(received)
To add a check that there is an actual message first could look like
received = radio.receive() if received is not None: display.scroll(received)
from microbit import * import radio radio.config(channel=10) radio.on() while True: display.clear() if button_a.was_pressed(): radio.send("iheart") if button_b.was_pressed(): radio.send("upset") incoming = radio.receive() if incoming == "iheart": display.show(Image.HEART) sleep(2000) elif incoming == "upset": display.show(Image.SAD) sleep(2000) else: display.set_pixel(2,2,9) sleep(100) display.set_pixel(2,2,0) sleep(100)