الخطوة 1: اصنعها
ماذا يعني؟
Send coded BBC micro:bit radio messages to tell someone how you’re feeling.
These two videos show you what you'll make and how to program it:
كيف يعمل ؟
- Press different button inputs on your micro:bit to send different messages over radio to another micro:bit to tell someone how you’re feeling. The output on the receiver micro:bit is either a happy, sad or excited emoji on the LED display.
- Make sure you and your partner use a unique radio group so that you can send your message to a particular micro:bit or a particular person who has that micro:bit.
- The program uses a simple kind of code, or encryption. This could stop, for example, another person from reading your messages, and keep them secure.
- The code used is a simple number cipher. This is a kind of encryption. In this example, 17 means happy, 23 means sad, and 42 means excited. Note - only numbers or letters can be sent by radio and not emojis.
- Agreeing a unique radio group, a set of possible messages, and a way of encrypting those messages with a partner means you have agreed a protocol, or rules for communicating and keeping your messages secure. Use this sheet to plan your own messaging protocol.
- The same code goes on both micro:bits, so you and your partner can communicate with each other.
ما تحتاجه
- جهازي مايكروبت (micro:bit)
- MakeCode or Python online editors
- حزم بطاريات (اختياري).
- Secure messaging planning sheet (optional)
الخطوة 2: برمجها
1from microbit import *
2import radio
3
4# The Python version of this project has sleep()
5# for each button press to make the A+B button work better
6
7radio.config(group=3)
8radio.on()
9
10while True:
11 if button_a.is_pressed() and button_b.is_pressed():
12 display.show(Image.SURPRISED)
13 radio.send('42')
14 sleep(300)
15 display.clear()
16 elif button_a.is_pressed():
17 display.show(Image.HAPPY)
18 radio.send('17')
19 sleep(300)
20 display.clear()
21 elif button_b.is_pressed():
22 display.show(Image.SAD)
23 radio.send('23')
24 sleep(300)
25 display.clear()
26
27 message = radio.receive()
28 if message:
29 if message == '17':
30 display.show(Image.HAPPY)
31 elif message == '23':
32 display.show(Image.SAD)
33 else:
34 display.show(Image.SURPRISED)
35 sleep(2000)
36 display.clear()
37 sleep(200)
الخطوة 3: حسّنها
- Customise the emojis to send different messages.
- Use more of the micro:bit’s physical inputs such as the shake gesture or the touch logo on the micro:bit V2 to send even more messages.
- Show scrolling text, such as the words 'hot', 'cold' and 'warm', instead of emojis to play a hide and seek game.
This content is published under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) licence.