■CurieIMU.stepsDetected関数
CurieIMU.hライブラリのCurieIMU.stepsDetected関数は、ステップ(歩く)が検出された場合にtrueを返します。
■使用例
CurieIMU.stepsDetected関数を使ったArduinoIDEのプログラム例は図1の通りです。このプログラムを実行すると、最初にCurieIMU.begin関数によりIMUモジュールが初期化され、loop関数中でCurieIMU.stepsDetected関数によってIMUモジュールに、歩く際に発生する加速度が加わると図2の様にシリアルモニタ上に「steps detected on」と表示します。
#include "CurieIMU.h" void setup() { Serial.begin(9600); // initialize Serial communication while (!Serial) ; // wait for serial port to connect.. /* Initialise the IMU */ CurieIMU.begin(); CurieIMU.attachInterrupt(eventCallback); CurieIMU.interrupts(CURIE_IMU_STEP); Serial.println("IMU initialisation complete, waiting for events..."); } void loop() {} static void eventCallback(void) { if (CurieIMU.getInterruptStatus(CURIE_IMU_STEP)) { if (CurieIMU.stepsDetected()) Serial.println("steps detected on"); } }
図1:プログラム例
図2:プログラム実行結果
■「CurieIMU.stepsDetected()」パラメータは有りません。
戻り値: ステップが検出された場合はtrue、それ以外はfalseを返します。
■その他関数
Curie IMUライブラリに関するその他関数については、コチラをご覧ください。
励みになりますのでよければクリック下さい(^o^)/