From 51ded228e0e99c28229e01e7c43a72d89a7de1c6 Mon Sep 17 00:00:00 2001 From: xdavidwu Date: Wed, 8 Jun 2022 23:13:22 +0800 Subject: [PATCH] add buttons reader for micro:bit to be used with buttonc --- microbit/buttons.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 microbit/buttons.py diff --git a/microbit/buttons.py b/microbit/buttons.py new file mode 100644 index 0000000..9b91fb7 --- /dev/null +++ b/microbit/buttons.py @@ -0,0 +1,13 @@ +from microbit import * + +a = False +b = False +while True: + ap = button_a.is_pressed() + bp = button_b.is_pressed() + if a != ap: + a = ap + print('A' if ap else 'a', end='') + if b != bp: + b = bp + print('B' if bp else 'b', end='') -- 2.45.2