これは MMA7361 3軸アナログ加速度センサ の Nucleo F401RE 用のライブラリです。詳しい説明はLibrary中のReadMe.hに記載しています。文字化けや開けない場合はダウンロードしてみてください。Google Chrome では見れるはずです。

Dependents:   Nucleo_L3GD20_MMA7361_Kalman

Revision:
1:3541f3ed831d
Parent:
0:ad6f3a862ed5
--- a/ReadMe.txt	Sun Feb 01 03:56:22 2015 +0000
+++ b/ReadMe.txt	Sun Feb 01 04:04:56 2015 +0000
@@ -150,4 +150,50 @@
  rad:変換したい値(ラジアン)
  値をラジアンから度に変換してそれを返します。角度、角速度、角加速度に対して使えます。
  πを初期では3.1415926535にしていますが、mma7361.h のなかで define されている PI の値を変更する
- ことで変えることができます。
\ No newline at end of file
+ ことで変えることができます。
+
+
+サンプルプログラム
+
+#include "mbed.h"
+#include "mma7361.h"
+
+Serial pc(USBTX,USBRX);
+
+DigitalOut myled(LED1);
+mma7361 a;
+
+int main() {
+    a.clear_mat();
+    a.show_mat();
+    int x,y;
+    a.set_1st_bit(&x,x_axis,0);
+    a.set_1st_bit(&y,y_axis,0);
+    float gx,gy,theta;
+    while(1){
+        a.low_pass_filter(&x,x_axis);
+        a.low_pass_filter(&y,y_axis);
+        gx=a.bit_to_g(x,x_axis);
+        gy=a.bit_to_g(y,y_axis);
+        theta=a.rotate(&x,x_axis,&y,y_axis);
+        theta=a.rad_to_deg(theta);
+        pc.printf("%.3fG %.3fG %.3f\n\r",gx,gy,theta);
+    }
+}
+
+
+実行結果
+
+31356 34040 28639
+32717 33388 31475
+15633 15797 15187
+5416 3220 7131
+-0.100G -0.130G 37.606
+-0.164G -0.233G 35.183
+-0.216G -0.321G 33.904
+-0.262G -0.401G 33.177
+-0.300G -0.470G 32.591
+-0.339G -0.535G 32.352
+-0.374G -0.593G 32.223
+-0.404G -0.645G 32.071
+-0.428G -0.689G 31.840
\ No newline at end of file