Bidirectional Texts

With unidirectional RF text working, the next step is bidirectional texting. Each micro:bit transceiver (transmitter/receiver) will take input that you type into its terminal and send it through the radio.  Each micro:bit will also receive radio messages and print them to the terminal.

IMPORTANT: The Send: prompt will not appear until you click inside the terminal and start typing.

  • If you are in a classroom, pair off and use your assigned channel.
  • Enter, save, and flash the program below into the first micro:bit module (Transceiver A).
  • Update the first print statement,  changing  print("micro:bit transceiver A")  to print("micro:bit transceiver B").
  • Flash the script into the second micro:bit module (Transceiver B).
  • Have fun typing messages to each other!
# Copyright Parallax Inc 2020 under MIT license

from microbit import *
import radio



print("micro:bit transceiver A")

print("Type messages, press enter to send.")
print("Received messages will also be displayed.")

while True:
    if uart.any():
        tx = input("Send: ")
    message = radio.receive()
    if message is not None:
        print("Receive: ", message)


Transceiver A


Transceiver B