bola y viga acelerometer
Dependencies: MMA8451Q Motor mbed-rtos mbed
Fork of FRDM_MMA8451Q by
Revision 8:59ea014845aa, committed 2016-12-01
- Comitter:
- yymoreno
- Date:
- Thu Dec 01 02:33:32 2016 +0000
- Parent:
- 7:70775be9f474
- Commit message:
- Bola y Viga acelerometer
Changed in this revision
diff -r 70775be9f474 -r 59ea014845aa Motor.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Motor.lib Thu Dec 01 02:33:32 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/simon/code/Motor/#f265e441bcd9
diff -r 70775be9f474 -r 59ea014845aa main.cpp --- 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); } }
diff -r 70775be9f474 -r 59ea014845aa mbed-rtos.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Thu Dec 01 02:33:32 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/mbed_official/code/mbed-rtos/#c825593ece39
diff -r 70775be9f474 -r 59ea014845aa mbed.bld --- a/mbed.bld Tue Feb 19 23:46:45 2013 +0000 +++ b/mbed.bld Thu Dec 01 02:33:32 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/3d0ef94e36ec \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/165afa46840b \ No newline at end of file