![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
I2C通信を使用した角速度測定、LCD表示サンプル
Dependencies: mbed mbed_mpu6050_i2c_raw_register AQM0802
main.cpp
- Committer:
- satoshi1204
- Date:
- 2018-12-13
- Revision:
- 1:6f743fe9a027
- Parent:
- 0:abd3a0fd55a9
- Child:
- 2:f2db52a742b0
File content as of revision 1:6f743fe9a027:
#include "mbed.h" #include "mpu6050.h" Serial pc(USBTX, USBRX); DigitalOut led1(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); DigitalOut led4(LED4); 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() { mpu.setMaxScale(MAX_ACC_8G, MAX_GYRO_1000degpersec); while(1) { led1 = 1; readData(); wait(0.2); led1 = 0; wait(0.2); } }