Students will learn how to use Python to send and receive text messages wirelessly using the radio module on a BBC micro:bit.
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.
Ensure students have Mu Editor installed. Connect the micro:bit to the computer via USB. Open Mu Editor and select "BBC micro:bit" mode.
Students will write a Python program to send a text message.
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()
Students will write a Python program to receive the transmitted message.
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
radio.on()
is included in both programs.button_b
to send a different message.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.
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.