チルトセンサー
-
class TiltSensor(port)
LEGO® Powered Up チルトセンサー。
- パラメータ:
port (Port) -- センサーが接続されているポート。
-
awaittilt() → Tuple[int, int]: deg
水平面に対する傾きを測定します。
- 戻り値:
ピッチ角とロール角のタプル。
サンプルコード
ピッチ角とロール角の計測。
from pybricks.pupdevices import TiltSensor
from pybricks.parameters import Port
from pybricks.tools import wait
# センサーを初期化。
accel = TiltSensor(Port.A)
while True:
# 水平面に対するチルト角度を読み取る。
pitch, roll = accel.tilt()
# 値を表示
print("Pitch:", pitch, "Roll:", roll)
# 何がプリントされているかが確認できるように待機。
wait(100)