bola y viga acelerometer

Dependencies:   MMA8451Q Motor mbed-rtos mbed

Fork of FRDM_MMA8451Q by mbed official

Revision:
8:59ea014845aa
Parent:
5:bf5becf7469c
--- a/main.cpp	Tue Feb 19 23:46:45 2013 +0000
+++ b/main.cpp	Thu Dec 01 02:33:32 2016 +0000
@@ -1,18 +1,33 @@
+// Sweep the motor speed from full-speed reverse (-1.0) to full speed forwards (1.0)
 #include "mbed.h"
 #include "MMA8451Q.h"
+#include "Motor.h"
+#include "rtos.h"
 
 #define MMA8451_I2C_ADDRESS (0x1d<<1)
+//Serial pc(USBTX,USBRX);
+Motor m(PTA5, PTA4, PTA12); // pwm, fwd, rev
+MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
+Serial pc(USBTX,USBRX);
+float s=0;
+
+void Lectura(void const *args) {
+    while (true) {
+        s = acc.getAccX();
+        Thread::wait(10);
+    }
+}
 
 int main(void) {
-    MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
-    PwmOut rled(LED_RED);
-    PwmOut gled(LED_GREEN);
-    PwmOut bled(LED_BLUE);
+     Thread thread(Lectura);
+    //PwmOut rled(LED_RED);
 
     while (true) {
-        rled = 1.0 - abs(acc.getAccX());
-        gled = 1.0 - abs(acc.getAccY());
-        bled = 1.0 - abs(acc.getAccZ());
-        wait(0.1);
+        //rled = 1.0 - abs(acc.getAccX());
+        //pc.printf("%f ",acc.getAccX());
+      // float s = acc.getAccX();
+       m.speed(s);
+       pc.printf("aceleracion: %f \r \n",s);
+       Thread::wait(100);
     }
 }