Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: MPU6050_test Drone MPU6050_test acelerometro ... more
MPU6050 Class Reference
API for MPC6050. More...
#include <MPU6050.h>
Public Member Functions | |
| MPU6050 (PinName sda, PinName scl) | |
| 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 | ||
| ) |
Create a MPU6050 Instance.
- Parameters:
-
sda SDA pin name of I2C scl SCL pin name of I2C
Definition at line 6 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 12 of file MPU6050.cpp.
Generated on Wed Jul 13 2022 11:22:57 by
1.7.2