Try This: Changing Frequencies

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.    

  • Make the changes to send_radio_test_message as shown below. Lines that have been added or changed are marked with comments.
  • Change the name of the project to  send_radio_test_message_try_this.
  • Save and then flash the modified script to the sender 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 terminal display from the sender micro:bit resembles this:

  • Check the terminal displaying 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: