a simple code with a not-so-simple mbed freeze
Dependencies: MPU6050 mbed-rtos mbed
Revision 0:b1322cbc592f, committed 2013-02-14
- Comitter:
- pommzorz
- Date:
- Thu Feb 14 20:12:51 2013 +0000
- Child:
- 1:d2011078309d
- Commit message:
- temps ech constant
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MPU6050.lib Thu Feb 14 20:12:51 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/garfieldsg/code/MPU6050/#662207e34fba
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Feb 14 20:12:51 2013 +0000
@@ -0,0 +1,73 @@
+#include "mbed.h"
+#include "MPU6050.h"
+
+
+DigitalOut myled(LED1);
+Serial pc(USBTX, USBRX);
+MPU6050 mpu(0x69);
+
+int16_t ax, ay, az;
+int16_t gx, gy, gz;
+int16_t moy[64];
+int comptFin=0;
+int comptDeb=0;
+int moyZ=0;
+
+void moyennage_Z()
+{
+ for (int n=0; n<64; n++) {
+ moyZ=moyZ+moy[n];
+
+
+ }
+ moyZ=moyZ/64;
+}
+
+
+
+
+int main()
+{
+ pc.printf("MPU6050 test\n\n\r");
+ pc.printf("MPU6050 initialize \n\r");
+
+ mpu.initialize();
+ pc.printf("MPU6050 testConnection \n\r");
+
+ bool mpu6050TestResult = mpu.testConnection();
+ if(mpu6050TestResult) {
+ pc.printf("MPU6050 test passed \n\r");
+
+ while(comptFin<64) {
+ mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
+ moy[comptFin]=az;
+ comptFin++;
+
+ }
+ moyennage_Z();
+ while(1) {
+ mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
+ moy[comptFin]=az;
+ comptFin++;
+ comptFin%=64;
+ moyZ-=moy[comptDeb]/64;
+ comptDeb++;
+ comptDeb%=64;
+ moyZ+=moy[comptFin]/64;
+ // moyennage_Z();
+ printf("%i\n\r",moyZ+17000);
+ wait(.001);
+
+
+
+
+
+ }
+
+
+ } else {
+ pc.printf("MPU6050 test failed \n\r");
+ }
+
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Feb 14 20:12:51 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/0954ebd79f59 \ No newline at end of file