Library receiving values from MPU6050
- include "mbed.h"
- include "TI_MPU6050.h"
Example
include the mbed library with this snippet
TI_MPU6050 mpu6050; DigitalOut led1(LED1); int main() { mpu6050.setSleepEnabled(false); while(1) { if (mpu6050.isHorizontal()) { led1 = 1; } else { led1 = 0; } int verticalAngle = mpu6050.getVerticalAngle(); printf("verticalAngle is %d\n\r", verticalAngle); } }
TI_MPU6050.h@1:bc1e8a435c95, 2018-06-04 (annotated)
- Committer:
- tichise
- Date:
- Mon Jun 04 22:41:56 2018 +0000
- Revision:
- 1:bc1e8a435c95
- Parent:
- IS_MPU6050.h@0:81e5563b1ea1
new
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tichise | 1:bc1e8a435c95 | 1 | #ifndef MBED_TI_MPU6050_H |
tichise | 1:bc1e8a435c95 | 2 | #define MBED_TI_MPU6050_H |
tichise | 0:81e5563b1ea1 | 3 | |
tichise | 0:81e5563b1ea1 | 4 | #include "mbed.h" |
tichise | 0:81e5563b1ea1 | 5 | #include "MPU6050.h" // https://os.mbed.com/users/garfieldsg/code/MPU6050/ |
tichise | 0:81e5563b1ea1 | 6 | |
tichise | 1:bc1e8a435c95 | 7 | class TI_MPU6050 |
tichise | 0:81e5563b1ea1 | 8 | { |
tichise | 0:81e5563b1ea1 | 9 | public: |
tichise | 1:bc1e8a435c95 | 10 | TI_MPU6050(); |
tichise | 0:81e5563b1ea1 | 11 | int getVerticalAngle(); |
tichise | 0:81e5563b1ea1 | 12 | bool isHorizontal(); |
tichise | 0:81e5563b1ea1 | 13 | void setSleepEnabled(bool enabled); |
tichise | 0:81e5563b1ea1 | 14 | |
tichise | 0:81e5563b1ea1 | 15 | private: |
tichise | 0:81e5563b1ea1 | 16 | MPU6050 _mpu; |
tichise | 0:81e5563b1ea1 | 17 | }; |
tichise | 0:81e5563b1ea1 | 18 | |
tichise | 0:81e5563b1ea1 | 19 | #endif |