Harry Keane
/
MPU6050I2C_FORBRED
MPU6050 with I2C. NO LCD
Diff: main.cpp
- Revision:
- 3:02533f8628e4
- Parent:
- 1:cea9d83b8636
- Child:
- 4:0bbb594dd933
diff -r e0381ca0edac -r 02533f8628e4 main.cpp --- a/main.cpp Sun Jun 29 21:53:23 2014 +0000 +++ b/main.cpp Sun Apr 19 13:04:46 2020 +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) @@ -47,8 +47,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); + int main() { @@ -59,8 +58,7 @@ t.start(); - lcd.init(); - lcd.setBrightness(0.05); + // Read the WHO_AM_I register, this is a good test of communication @@ -71,8 +69,7 @@ { pc.printf("MPU6050 is online..."); wait(1); - lcd.clear(); - lcd.printString("MPU6050 OK", 0, 0); + mpu6050.MPU6050SelfTest(SelfTest); // Start by performing self test and reporting values @@ -90,20 +87,13 @@ 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); + } } else @@ -111,10 +101,7 @@ 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 } @@ -161,8 +148,8 @@ mpu6050.MadgwickQuaternionUpdate(ax, ay, az, gx*PI/180.0f, gy*PI/180.0f, gz*PI/180.0f); // Serial print and/or display at 0.5 s rate independent of data rates - delt_t = t.read_ms() - count; - if (delt_t > 500) { // update LCD once per half-second independent of read rate + // delt_t = t.read_ms() - count; + // if (delt_t > 500) { // update LCD once per half-second independent of read rate pc.printf("ax = %f", 1000*ax); pc.printf(" ay = %f", 1000*ay); @@ -179,12 +166,7 @@ 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. @@ -215,10 +197,12 @@ pc.printf("average rate = %f\n\r", (float) sumCount/sum); myled= !myled; - count = t.read_ms(); + // count = t.read_ms(); sum = 0; sumCount = 0; + + //wait(0.5); //So i can read the data } } - } \ No newline at end of file + \ No newline at end of file