bola y viga acelerometer
Dependencies: MMA8451Q Motor mbed-rtos mbed
Fork of FRDM_MMA8451Q by
main.cpp@8:59ea014845aa, 2016-12-01 (annotated)
- Committer:
- yymoreno
- Date:
- Thu Dec 01 02:33:32 2016 +0000
- Revision:
- 8:59ea014845aa
- Parent:
- 5:bf5becf7469c
Bola y Viga acelerometer
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yymoreno | 8:59ea014845aa | 1 | // Sweep the motor speed from full-speed reverse (-1.0) to full speed forwards (1.0) |
chris | 2:41db78380a6e | 2 | #include "mbed.h" |
chris | 2:41db78380a6e | 3 | #include "MMA8451Q.h" |
yymoreno | 8:59ea014845aa | 4 | #include "Motor.h" |
yymoreno | 8:59ea014845aa | 5 | #include "rtos.h" |
chris | 2:41db78380a6e | 6 | |
chris | 2:41db78380a6e | 7 | #define MMA8451_I2C_ADDRESS (0x1d<<1) |
yymoreno | 8:59ea014845aa | 8 | //Serial pc(USBTX,USBRX); |
yymoreno | 8:59ea014845aa | 9 | Motor m(PTA5, PTA4, PTA12); // pwm, fwd, rev |
yymoreno | 8:59ea014845aa | 10 | MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); |
yymoreno | 8:59ea014845aa | 11 | Serial pc(USBTX,USBRX); |
yymoreno | 8:59ea014845aa | 12 | float s=0; |
yymoreno | 8:59ea014845aa | 13 | |
yymoreno | 8:59ea014845aa | 14 | void Lectura(void const *args) { |
yymoreno | 8:59ea014845aa | 15 | while (true) { |
yymoreno | 8:59ea014845aa | 16 | s = acc.getAccX(); |
yymoreno | 8:59ea014845aa | 17 | Thread::wait(10); |
yymoreno | 8:59ea014845aa | 18 | } |
yymoreno | 8:59ea014845aa | 19 | } |
chris | 2:41db78380a6e | 20 | |
chris | 4:367de1084ea9 | 21 | int main(void) { |
yymoreno | 8:59ea014845aa | 22 | Thread thread(Lectura); |
yymoreno | 8:59ea014845aa | 23 | //PwmOut rled(LED_RED); |
chris | 4:367de1084ea9 | 24 | |
emilmont | 5:bf5becf7469c | 25 | while (true) { |
yymoreno | 8:59ea014845aa | 26 | //rled = 1.0 - abs(acc.getAccX()); |
yymoreno | 8:59ea014845aa | 27 | //pc.printf("%f ",acc.getAccX()); |
yymoreno | 8:59ea014845aa | 28 | // float s = acc.getAccX(); |
yymoreno | 8:59ea014845aa | 29 | m.speed(s); |
yymoreno | 8:59ea014845aa | 30 | pc.printf("aceleracion: %f \r \n",s); |
yymoreno | 8:59ea014845aa | 31 | Thread::wait(100); |
chris | 2:41db78380a6e | 32 | } |
chris | 2:41db78380a6e | 33 | } |