3軸加速度センサーを使ってみる
パソコンとのシリアル通信とADCの記事を書いたので、
今度は加速度センサーの値を取得してみる。
加速度センサー:KXM52-1052
include the mbed library with this snippet
#include "mbed.h" Serial pc(USBTX, USBRX); // tx, rx AnalogIn ainZ(p15); AnalogIn ainY(p16); AnalogIn ainX(p17); int main() { while(1) { pc.printf("x:%1.3f y:%1.3f z:%1.3f \r\n", ainX.read(),ainY.read(),ainZ.read()); wait(0.5); } }
Please log in to post comments.