der
Dependencies: mbed MPU6050 TextLCD
Revision 0:304aaa70b2e8, committed 2020-05-06
- Comitter:
- 20172573073
- Date:
- Wed May 06 03:15:37 2020 +0000
- Commit message:
- acelerometro
Changed in this revision
diff -r 000000000000 -r 304aaa70b2e8 MPU6050.lib --- /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
diff -r 000000000000 -r 304aaa70b2e8 TextLCD.lib --- /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
diff -r 000000000000 -r 304aaa70b2e8 main.cpp --- /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); + + } +} + +////////////////////////////////////////////////////////////////////////////////////////////////////// + +
diff -r 000000000000 -r 304aaa70b2e8 mbed.bld --- /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