Satoshi Iyobe / MPU6050

Dependents:   measure_1_BBB measure_1_CCC measure_1_DDD

Revision:
1:c9dc906f8b9f
Parent:
0:3045b1e4107b
Child:
2:8622f361c1a4
--- a/MPU6050.cpp	Fri May 07 03:27:37 2021 +0000
+++ b/MPU6050.cpp	Thu May 13 05:11:28 2021 +0000
@@ -16,7 +16,7 @@
 {
     write_reg(ADDRESS,MPU6050_PWR_MGMT_1,0x00);//disable sleep mode
     write_reg(ADDRESS,MPU6050_GYRO_CONFIG,0x10);//gyro +-1000deg/s
-    write_reg(ADDRESS,MPU6050_ACCEL_CONFIG,0x08);//accel +-4G
+    write_reg(ADDRESS,MPU6050_ACCEL_CONFIG,0x18);//accel +-4G
     write_reg(ADDRESS,MPU6050_SMPLRT_DIV,0x10);//sample rate 470Hz
     //to set more, see MPU6000 Register Map
 }
@@ -61,7 +61,17 @@
     }
     return false;
 }
-
+bool MPU6050::readraw2(int *ax, int *ay, int *az)
+{
+    char data2[6];
+    if (read_data(ADDRESS, MPU6050_ACCEL_XOUT_H, data2, 6)) {
+        *ax = int(short(data2[0] << 8 | data2[1]));
+        *ay =  int(short(data2[2] << 8 | data2[3]));
+        *az =  int(short(data2[4] << 8 | data2[5]));
+        return true;
+    }
+    return false;
+}
 bool MPU6050::write_reg(int addr_i2c,int addr_reg, char v)
 {
     char data[2] = {addr_reg, v};