Working with radio
The Micro:bit comes with a built-in 2.4 GHz radio module. Using the built-in library radio, we can send and receive messages wirelessly. For demonstrations of the radio functionality, we do not need to create a circuit. We are ready to go by just powering up a few Micro:bit devices.
Turning the radio on and off
We can get started by turning the radio of a Micro:bit on and off with the following simple code executed in a REPL:
>>> from microbit import * >>> import radio >>> radio.on() >>> radio.off()
Let’s learn to send and receive messages.
Sending and receiving messages
We can send messages with the built-in radio.send()
method. The maximum length of the string that can be sent with this method is 250 characters. Let’s write the code for a transmitter routine:
from microbit import * import radio try: radio.on() while True: ...