Código de pruebas para sensor Flex + IMU

Dependencies:   mbed BMX055

Files at this revision

API Documentation at this revision

Comitter:
ramchagar
Date:
Mon May 13 20:28:49 2019 +0000
Commit message:
Codigo de prueba IMU

Changed in this revision

BMX055.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
diff -r 000000000000 -r dfc579990bfa BMX055.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BMX055.lib	Mon May 13 20:28:49 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/kenjiArai/code/BMX055/#1bea0ef16d84
diff -r 000000000000 -r dfc579990bfa main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon May 13 20:28:49 2019 +0000
@@ -0,0 +1,47 @@
+#include    "mbed.h"
+#include    "BMX055.h"
+
+Serial pc(USBTX,USBRX);
+I2C i2c(I2C_SDA, I2C_SCL);
+BMX055 imu(i2c);
+AnalogIn ain(A0); 
+DigitalOut myled(LED2);
+
+const BMX055_TypeDef bmx055_my_parameters = {
+// ACC
+ACC_2G,
+ACC_BW250Hz,
+// GYR
+GYR_125DPS,
+GYR_200Hz23Hz,
+// MAG
+MAG_ODR10Hz
+};
+
+int main() {
+    BMX055_ACCEL_TypeDef  acc;
+    BMX055_GYRO_TypeDef   gyr;
+    BMX055_MAGNET_TypeDef mag;
+    
+    //while (imu.chip_ready() == 0){
+//        pc.printf("Bosch BMX055 is NOT avirable!!\r\n");
+//        wait(1);
+//    }
+    
+    imu.set_parameter(&bmx055_my_parameters);
+    while(1) {
+        imu.get_accel(&acc);
+        pc.printf("ACC: x=%+3.2f y=%+3.2f z=%+3.2f\r\n", acc.x, acc.y, acc.z);
+        imu.get_gyro(&gyr);
+        pc.printf("GYR: x=%+3.2f y=%+3.2f z=%+3.2f\r\n", gyr.x, gyr.y, gyr.z);
+        imu.get_magnet(&mag);
+        pc.printf("MAG: x=%+3.2f y=%+3.2f z=%+3.2f\r\n", mag.x, mag.y, mag.z);
+        wait(0.5f);
+        wait(1);
+        myled = !myled; 
+        float f=ain.read();
+        pc.printf("value f %f \n",f); 
+        float voltage =(f*(5.0f)); 
+        pc.printf("value voltage %f \n",voltage);
+   }
+}
\ No newline at end of file
diff -r 000000000000 -r dfc579990bfa mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon May 13 20:28:49 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file