-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (29 loc) · 701 Bytes
/
Copy pathmain.py
File metadata and controls
38 lines (29 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from microbit import *
import radio
# --- SETUP
# start sensors
# store variables
radio.config(channel=7)
# --- RUNNING
while True:
# -- transmitting
# read sensor data
a_pressed = button_a.was_pressed()
b_pressed = button_b.was_pressed()
# process data
# output data
if a_pressed:
radio.send("happy")
display.show("A")
elif b_pressed:
radio.send("sad")
display.show("B")
# -- recieving
# read sensor data
incoming = radio.receive()
# process data
# output data
if incoming == "happy":
display.show(Image.HAPPY)
elif incoming == "sad":
display.show(Image.SAD)