der

Dependencies:   mbed MPU6050 TextLCD

Files at this revision

API Documentation at this revision

Comitter:
20172573073
Date:
Wed May 06 03:15:37 2020 +0000
Commit message:
acelerometro

Changed in this revision

MPU6050.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MPU6050.lib	Wed May 06 03:15:37 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/ritarosakai/code/MPU6050/#002d3ac85242
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Wed May 06 03:15:37 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/simon/code/TextLCD/#308d188a2d3a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed May 06 03:15:37 2020 +0000
@@ -0,0 +1,57 @@
+#include "mbed.h"
+#include "MPU6050.h"
+#include "TextLCD.h"
+
+MPU6050 mpu(A4,A5);
+Serial pc(USBTX, USBRX);
+TextLCD lcd(PTB18,PTB19,PTC0,PTC4,PTC6,PTC7, TextLCD::LCD16x2 );
+Timer timer;
+int gx,gy,gz,ax,ay,az;
+long tiempo_prev;
+float dt,giro1x,giro1z,giro2x,giro2z,giro1y,giro2y;
+
+int main()
+{
+    timer.start();
+    if(mpu.getID()==0x68) {
+        lcd.cls();
+        lcd.printf("MPU6050 OK");
+        wait(1);
+    } else {
+        lcd.cls();
+        lcd.printf("MPU6050 error ID=0x%x\r\n",mpu.getID());
+        while(1) {
+        }
+    }
+    mpu.start();
+    tiempo_prev=timer.read_ms();
+    while(1) {
+
+        mpu.readraw(&gx,&gy,&gz,&ax,&ay,&az);
+        dt =(timer.read_ms() - tiempo_prev);
+        tiempo_prev=timer.read_ms();
+       
+       
+        giro1x=(gx/131)*dt/1000.0+giro2x;
+        giro1z=(gz/131)*dt/1000.0+giro2z;
+        giro1y=(gy/131)*dt/1000.0+giro2y;
+        giro2x=giro1x;
+        giro2z=giro1z;
+        giro2y=giro1y;
+       lcd.cls();
+        lcd.printf("z: %f",giro1z);
+       wait(1);
+       lcd.cls();
+        lcd.printf("x: %f",giro1x);
+       wait(1);
+        lcd.cls();
+        lcd.printf("y: %f ",giro1y);
+       wait(1);
+        //pc.printf("Der: %5.1f ,Izq: %5.1f ",tDer,tIzq);
+        
+    }
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed May 06 03:15:37 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file