micro_python_getMotorCurrent - aks3g/ai_mini_4wd_kit GitHub Wiki

Machine.getMotorCurrent

grab()で更新したセンサデータのうち、モーターに流れている電流値をmA単位で取得します。

定義

def getMotorCurrent()

引数

なし

戻り値

float - モーター電流[mA]

サンプルコード

センサデータを取得し、モーター電流値をプリントするサンプル

import mini4wd

m=mini4wd.Machine()

m.grab()
print (str(m.getMotorCurrent()))

m.setDuty(128)
cnt = 0
while cnt < 52:
    cnt = cnt + 1
    m.grab()

print (str(m.getMotorCurrent()))

m.setDuty(255)
cnt = 0
while cnt < 52:
    cnt = cnt + 1
    m.grab()

print (str(m.getMotorCurrent()))