Andrew Olguin
/
MPU6050IMU
Example for using MPU6050 code
Fork of MPU6050IMU by
Diff: main.cpp
- Revision:
- 3:a6f9a7fdef60
- Parent:
- 1:cea9d83b8636
diff -r e0381ca0edac -r a6f9a7fdef60 main.cpp --- a/main.cpp Sun Jun 29 21:53:23 2014 +0000 +++ b/main.cpp Sat Jun 11 18:56:06 2016 +0000 @@ -28,7 +28,7 @@ #include "mbed.h" #include "MPU6050.h" -#include "N5110.h" +//#include "N5110.h" // Using NOKIA 5110 monochrome 84 x 48 pixel display // pin 9 - Serial clock out (SCLK) @@ -48,7 +48,7 @@ Serial pc(USBTX, USBRX); // tx, rx // VCC, SCE, RST, D/C, MOSI,S CLK, LED - N5110 lcd(PA_8, PB_10, PA_9, PA_6, PA_7, PA_5, PC_7); + // N5110 lcd(PA_8, PB_10, PA_9, PA_6, PA_7, PA_5, PC_7); int main() { @@ -59,8 +59,8 @@ t.start(); - lcd.init(); - lcd.setBrightness(0.05); + //lcd.init(); + //lcd.setBrightness(0.05); // Read the WHO_AM_I register, this is a good test of communication @@ -71,8 +71,8 @@ { pc.printf("MPU6050 is online..."); wait(1); - lcd.clear(); - lcd.printString("MPU6050 OK", 0, 0); + //lcd.clear(); + //lcd.printString("MPU6050 OK", 0, 0); mpu6050.MPU6050SelfTest(SelfTest); // Start by performing self test and reporting values @@ -89,21 +89,11 @@ mpu6050.resetMPU6050(); // Reset registers to default in preparation for device calibration mpu6050.calibrateMPU6050(gyroBias, accelBias); // Calibrate gyro and accelerometers, load biases in bias registers mpu6050.initMPU6050(); pc.printf("MPU6050 initialized for active data mode....\n\r"); // Initialize device for active mode read of acclerometer, gyroscope, and temperature - - lcd.clear(); - lcd.printString("MPU6050", 0, 0); - lcd.printString("pass self test", 0, 1); - lcd.printString("initializing", 0, 2); wait(2); } else { - pc.printf("Device did not the pass self-test!\n\r"); - - lcd.clear(); - lcd.printString("MPU6050", 0, 0); - lcd.printString("no pass", 0, 1); - lcd.printString("self test", 0, 2); + pc.printf("Device did not the pass self-test!\n\r"); } } else @@ -111,11 +101,6 @@ pc.printf("Could not connect to MPU6050: \n\r"); pc.printf("%#x \n", whoami); - lcd.clear(); - lcd.printString("MPU6050", 0, 0); - lcd.printString("no connection", 0, 1); - lcd.printString("0x", 0, 2); lcd.setXYAddress(20, 2); lcd.printChar(whoami); - while(1) ; // Loop forever if communication doesn't happen } @@ -178,15 +163,7 @@ pc.printf("q1 = %f\n\r", q[1]); pc.printf("q2 = %f\n\r", q[2]); pc.printf("q3 = %f\n\r", q[3]); - - lcd.clear(); - lcd.printString("MPU6050", 0, 0); - lcd.printString("x y z", 0, 1); - lcd.setXYAddress(0, 2); lcd.printChar((char)(1000*ax)); - lcd.setXYAddress(20, 2); lcd.printChar((char)(1000*ay)); - lcd.setXYAddress(40, 2); lcd.printChar((char)(1000*az)); lcd.printString("mg", 66, 2); - - + // Define output variables from updated quaternion---these are Tait-Bryan angles, commonly used in aircraft orientation. // In this coordinate system, the positive z-axis is down toward Earth. // Yaw is the angle between Sensor x-axis and Earth magnetic North (or true North if corrected for local declination, looking down on the sensor positive yaw is counterclockwise.