Earthquake detector

Dependencies:   mbed MPU6050

main.cpp

Committer:
Alvaro13
Date:
2019-07-26
Revision:
3:371e35f9769a
Parent:
2:4fa4c952883a
Parent:
1:741df8410d1f
Child:
4:16b60914d174

File content as of revision 3:371e35f9769a:

#include "mbed.h"
#include "MPU6050.h"
#include "REFVALUES.h"
//activo
// Debbuging led
DigitalOut myled(LED1);
// klkl
// Puerto serial
Serial pc(USBTX, USBRX);

// Objeto MPU6050
MPU6050 mpu(PF_15, PF_14);

// Threads
Thread sampleAccelero();
Thread printDebug();
 




int main() {
    
    pc.baud(9600);
    
    
    
    float acce[3];
    
    mpu.setAcceleroRange(2);
    mpu.setBW(6);
   
    // Test the connection
    if (mpu.testConnection())
        pc.printf("MPU6050 test passed \r\n");    
    else
        pc.printf("MPU6050 test failed \r\n");
    
    
    float x;
    float y;
    
    while(1) {
        
        wait(0.016);
        mpu.getAccelero(acce);
        
        
        x = (float)acce[0] / (9.81);
        y = (float)acce[1] / (9.81);
            
        
        //pc.printf("X = %f  \t Y = %f \t Z = %f \r\n", x , y, z);
        pc.printf("X = %f  \t Y = %f \r\n", x , y);
        //pc.printf("%f\r\n", x);
    
    }
}