I2C通信を使用した角速度測定、LCD表示サンプル

Dependencies:   mbed mbed_mpu6050_i2c_raw_register AQM0802

main.cpp

Committer:
satoshi1204
Date:
2018-12-12
Revision:
0:abd3a0fd55a9
Child:
1:6f743fe9a027

File content as of revision 0:abd3a0fd55a9:

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

DigitalOut myled(LED1);
Serial pc(USBTX, USBRX);
MPU6050 mpu(p9, p10);

void readData()
{
    double ax, ay, az;
    mpu.readAccelemeter(ax, ay, az);
    double gx, gy, gz;
    mpu.readGyroscope(gx, gy, gz);
    pc.printf("%.4lf %.4lf %.4lf %.4lf %.4lf %.4lf\r\n", ax, ay, az, gx, gy, gz);
}

int main() {
    int acc, gyro;
    mpu.setMaxScale(MAX_ACC_8G, MAX_GYRO_1000degpersec);
    mpu.getMaxScale(acc, gyro);
    pc.printf("%x %x\r\n", acc, gyro);
    while(1) {
        myled = 1;
        readData();
        wait(0.2);
        myled = 0;
        wait(0.2);
    }
}