AAAAAAAAAAAAAA
MPU6050 Class Reference
API for MPC6050. More...
#include <MPU6050.h>
Public Member Functions | |
| MPU6050 (PinName sda, PinName scl, int address) | |
| Create a MPU6050 Instance. | |
| void | start (void) |
| Init MCP6050. | |
| char | getID (void) |
| Get WHO_AM_I. | |
| bool | read (float *gx, float *gy, float *gz, float *ax, float *ay, float *az) |
| Get data in float. | |
| bool | readraw (int *gx, int *gy, int *gz, int *ax, int *ay, int *az) |
| Get data in int. | |
Detailed Description
API for MPC6050.
MCP6050 is a 6-axis I2C sensor
#include "mbed.h" #include "MPU6050.h" MPU6050 mpu(D7,D8); float gx,gy,gz,ax,ay,az; int main() { if(mpu.getID()==0x68) { printf("MPU6050 OK"); wait(1); } else { printf("MPU6050 error ID=0x%x\r\n",mpu.getID()); while(1) { } } mpu.start(); while(1) { mpu.read(&gx,&gy,&gz,&ax,&ay,&az); printf("gx,gy,gz,ax,ay,az %.1f,%.1f,%.1f,%.2f,%.2f,%.2f\r\n",gx,gy,gz,ax,ay,az); wait(0.1); } } *
Definition at line 149 of file MPU6050.h.
Constructor & Destructor Documentation
| MPU6050 | ( | PinName | sda, |
| PinName | scl, | ||
| int | address | ||
| ) |
Create a MPU6050 Instance.
- Parameters:
-
sda SDA pin name of I2C scl SCL pin name of I2C
Definition at line 8 of file MPU6050.cpp.
Member Function Documentation
| char getID | ( | void | ) |
| bool read | ( | float * | gx, |
| float * | gy, | ||
| float * | gz, | ||
| float * | ax, | ||
| float * | ay, | ||
| float * | az | ||
| ) |
| bool readraw | ( | int * | gx, |
| int * | gy, | ||
| int * | gz, | ||
| int * | ax, | ||
| int * | ay, | ||
| int * | az | ||
| ) |
| void start | ( | void | ) |
Init MCP6050.
Disable sleep mode Set gyro range as +- 1000 deg/s Set accel range as +- 4G Set sample rate as 470 Hz
Definition at line 15 of file MPU6050.cpp.
Generated on Sun Jul 17 2022 04:39:01 by
1.7.2