Micro:bit Radio Communication Lesson

Grade Level: High School

Subject: Computer Science / Electronics

Time Required: ~60 minutes

Objective

Students will learn how to use Python to send and receive text messages wirelessly using the radio module on a BBC micro:bit.

Materials Needed

Lesson Outline

1. Introduction to Radio Communication (10 minutes)

Explain how radio waves are used for wireless communication. Discuss real-world applications: Bluetooth, WiFi, walkie-talkies. Introduce the micro:bit radio module, which allows devices to send and receive messages.

2. Setting Up the Micro:bit (10 minutes)

Ensure students have Mu Editor installed. Connect the micro:bit to the computer via USB. Open Mu Editor and select "BBC micro:bit" mode.

3. Writing the Code for the Transmitter (15 minutes)

Students will write a Python program to send a text message.

Code for the Transmitter (Sending Messages)

from microbit import * import radio radio.on() # Turn on the radio radio.config(channel=7) # Set channel (0-100) while True: if button_a.was_pressed(): # If button A is pressed radio.send("Hello from Microbit!") # Send a message display.show("T") # Indicate transmission sleep(500) display.clear()

4. Writing the Code for the Receiver (15 minutes)

Students will write a Python program to receive the transmitted message.

Code for the Receiver (Receiving Messages)

from microbit import * import radio radio.on() # Turn on the radio radio.config(channel=7) # Ensure the same channel as the sender while True: message = radio.receive() # Check for a message if message: display.scroll(message) # Scroll received message

5. Testing & Debugging (10 minutes)

Extensions & Challenges

  1. Customize the Message - Modify the code to send user-input messages. Use button_b to send a different message.
  2. Two-Way Communication - Add a second transmitter-receiver pair for a conversation.
  3. Encrypt the Messages - Use a simple Caesar cipher to encrypt/decrypt messages before sending.
  4. Increase the Range - Experiment with different radio power levels (radio.config(power=0-7)).
Purpose: You will be using the Micro:bit physical Hardware.

In this lesson, you will write a Python program to run on the micro:bit 
that will learn the Microbit Hardware.
Your video will be of the actual Micro:Bit hardware.

You will drop off 8 files into Google Classroom:
	• Your files will be: (Remember the python program is dropped off first.)
		• PX_lastname_RadioSend.py (Python program)
		• PX_lastname_RadioReceive.py (Python program)
		• PX_lastname_RadioSend.hex (Hex file for Microbit hardware)
		• PX_lastname_RadioReceive.hex (Hex file for Microbit hardware)
		• PX_lastname_RadioSend.png (Screenshot)
		• PX_lastname_RadioReceive.png (Screenshot)
		• PX_lastname_RadioSend.mp4 (Video running the program on the micro:bit Hardware)
		• PX_lastname_RadioReceive.mp4 (Video running the program on the micro:bit Hardware)

            
              Current Resources needed:
                 Launch the Micro:Bit Python interpreter
                 At this time you will run your code.
                 Use the online Microbit but still download the hex file for hardware use.

            
                 If you do not understand this assignment,
                 ask Mr. Cusack and/or attend tutorials.
        

Conclusion & Recap

Discuss how radio communication can be used in real-world applications. Ask students to reflect on what they learned about micro:bit communication. Discuss how they could improve or expand their project.