Changing frequencies is a common practice for aircraft and watercraft radio operators. As airplanes near certain airports, their pilots will switch their radio frequencies to communicate on the airport’s channel. The same applies to ships which use certain radio channels when communicating offshore and other channels when in certain ports.
The send_radio_test_message script can be modified to send different messages on different channels. Then, the receiver micro:bit will then display only the messages that go to whatever channel it’s set to.
- Set the project name to send_radio_test_message_try_this.
- Make the changes to send_radio_test_message as shown below. Lines that have been added or changed are marked with comments.
- Click Save, and then click Send to micro:bit.
# send_radio_test_message_try_this # change from microbit import * import radio radio.on() sleep(1000) print("micro:bit radio sender") while True: radio.config(channel = 7) # move to here message = "Hello from channel 7!" # change print("Send: ", message) radio.send(message) sleep(1000) # add radio.config(channel = 14) # add message = "Hello from channel 14!" # add print("Send: ", message) # add radio.send(message) # add print("Done!") sleep(1000) # change
- Verify that the serial monitor messages from the sender micro:bit resemble this:
- Check the serial monitor messages from the micro:bit that’s running the receive_radio_test_message script.
- Verify that the content resembles this:
- Open and find this line in the receive_radio_test_message script:
radio.config(channel = 7)
- Change it to this:
radio.config(channel = 14)
- Change the project name to receive_radio_test_message_try_this.
- Save the project.
- Connect to the receiver micro:bit and flash the modified script.
- Verify that its terminal output now resembles this: