加速度センサのプログラムです(zの政府で判断、PCに表示)

Dependencies:   mbed

mpu6050.cpp

Committer:
Nryo
Date:
2019-11-19
Revision:
1:8d3dd0d73048
Parent:
0:d8462d09ff84

File content as of revision 1:8d3dd0d73048:

#include "mbed.h"
#include "mpu6050.h"


MPU6050 mpu(p9,p10);

int main() {
        
        int accel[3];//accを定義。
    while(1){
        mpu.readAccelData(accel);//加速度の値をacc[3]に代入
        int x = accel[0];//x軸方向の加速度
        int y = accel[1];//y軸方向の加速度
        int z = accel[2];//z軸方向の加速度

        printf("x:%06d y:%06d z:%06d\r\n",x,y,z);
        wait(0.01);
    }
}