micro:bitのセンサー値のうち「傾き(前後)」の値を取得します。
なし
傾き(前後)の値 (-180~+180) ※単位は「°(度)」
# 傾き(前後/左右)の値をリアルタイムで画面に表示します
UI.label(10, 10, 250, 24, "前後の傾き(pitch) : ", {fontsize: 24})
UI.label(10, 50, 250, 24, "左右の傾き(roll) : ", {fontsize: 24})
label_p = UI.label(280, 10, 100, 24, "", {color: 'blue', fontsize: 24})
label_r = UI.label(280, 50, 100, 24, "", {color: 'blue', fontsize: 24})
mb = Microbit.new
mb.on_notify do
label_p.value = "#{mb.pitch}"
label_r.value = "#{mb.roll}"
end
mb.connect do
end