MicroPython メモ 9 / ステートマシン / それに意味のないとき
参考: Programming the BBC micro:bit: Getting Started with MicroPython, pp.59-65
from microbit import * state = "A" def handle_A_state(): global state if button_b.is_pressed(): state = "B" display.show(state) def handle_B_state(): global state if button_a.is_pressed(): state = "A" display.show(state) while True: if state == "A": handle_A_state() elif state == "B": handle_B_state()