mpu6050

Dependencies:   MPU6050 mbed

main.cpp

Committer:
oakx
Date:
2014-07-02
Revision:
0:db87af04ff89

File content as of revision 0:db87af04ff89:

#include "mbed.h"
#include "MPU6050.h"
 
DigitalOut myled(LED1);
Serial pc(USBTX, USBRX);
MPU6050 mpu;
 
int16_t ax, ay, az;
int16_t gx, gy, gz;
 
int main()
{
    pc.baud(9600);
    pc.printf("MPU6050 test\n\n");
    pc.printf("MPU6050 initialize \n");
 
    mpu.initialize();
    pc.printf("MPU6050 testConnection \n");
 
      bool mpu6050TestResult = mpu.testConnection();
    if(mpu6050TestResult) {
        pc.printf("MPU6050 test passed \n");
    } else {
        pc.printf("MPU6050 test failed \n");
    }
   
    while(1) {
        wait(1);
        mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
        //writing current accelerometer and gyro position 
        pc.printf("ax = %d ,ay = %d ,az = %d , gx = %d, gy = %d, gz = %d\n",ax,ay,az,gx,gy,gz);
    }
    
}