![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
I2C通信を使用した角速度測定、LCD表示サンプル
Dependencies: mbed mbed_mpu6050_i2c_raw_register AQM0802
mpu6050.h
- Committer:
- satoshi1204
- Date:
- 2018-12-12
- Revision:
- 0:abd3a0fd55a9
- Child:
- 1:6f743fe9a027
File content as of revision 0:abd3a0fd55a9:
#include "mbed.h" enum { MAX_ACC_2G, MAX_ACC_4G, MAX_ACC_8G, MAX_ACC_16G, }; enum { MAX_GYRO_250degpersec, MAX_GYRO_500degpersec, MAX_GYRO_1000degpersec, MAX_GYRO_2000degpersec, }; class MPU6050 { public: MPU6050(PinName i2c_sda, PinName i2c_scl); ~MPU6050(); void readAccelemeter(double &acc_x, double &acc_y, double &acc_z); void readGyroscope(double &gyro_x, double &gyro_y, double &gyro_z); void setMaxScale(int max_acc, int max_gyro); void getMaxScale(int &acc, int &gyro); private: I2C i2c; int address; double rate_accelemeter; double rate_gyroscope; char readByte(char reg); void writeByte(char reg, char data); };