使用micro:bit結合micropython測速度

from microbit import *


max = 0


while True:

sleep(20)

x = accelerometer.get_x()

y = accelerometer.get_y()

z = accelerometer.get_z()

total = x**2 + y**2 + z**2

total = total ** 0.5

total = total ** 0.5

total = int(total)

if total > max :

max = total

print(total,max)



if button_a.is_pressed():

max = 0

if button_b.is_pressed():

display.scroll(max)