いろんな人がサンプルを作っていて新しさはないけど。。教材用のメモ
micro:bit(その1)でAボタンを押すと・・・
import utime from microbit import button_a import radio radio.on() while True: if button_a.was_pressed(): print("pressed") radio.send("a_is_pressed") utime.sleep(1) radio.off()
micro:bit(その2)で"a_is_pressed"とLEDマトリクスに表示される
import utime from microbit import display import radio radio.on() while True: msg = radio.receive() if msg: print(msg) display.scroll(msg) else: print('zzz') utime.sleep(1) radio.off()
■追記
str型の変換覚書
[f"[{chr(ord(x))}]({hex(ord(x))})" for x in 'Hello world!'] ['[H](0x48)', '[e](0x65)', '[l](0x6c)', '[l](0x6c)', '[o](0x6f)', '[ ](0x20)', '[w](0x77)', '[o](0x6f)', '[r](0x72)', '[l](0x6c)', '[d](0x64)', '[!](0x21)']