2.16. Exercise: SOS#
Warning
This is a pair or group exercise.
Pair up with a partner or form a small group
Navigate to the MicroPython editor https://python.microbit.org/v/3. If you already have it open, then use that existing window or tab.
Connect your micro:bit using the instructions on the previous page
Decide on a channel to use in your pair or group
Enter the following code into the editor and change your channel
from microbit import *
import radio
radio.config(channel=7)
while True:
msg = radio.receive()
if msg:
print(msg)
sleep(200)
Flash the code to your micro:bit.
If you get stuck ask a peer or your teacher for help!
Question 1
Extend your code to:
Extend the code to send a message on your channel when the A button is pressed
Solution
from microbit import *
import radio
radio.config(channel=7)
while True:
msg = radio.receive()
if msg:
print(msg)
if button_a.is_pressed():
radio.send("SOS")
sleep(200)
Question 2
Extend your code to:
Extend the code to send a message on your channel when the A button is pressed
Solution
Solution is locked