Olivia Itzel Solano
/
Contador_De_Pasos
Contador de pasos
gilberto.h
- Committer:
- gilbertogn
- Date:
- 2016-02-14
- Revision:
- 11:49b4472e155f
- Parent:
- 8:bf6fa71e6999
File content as of revision 11:49b4472e155f:
#include "mbed.h" #include "mbed.h" #include "MMA8451Q.h" #define MMA8451_I2C_ADDRESS (0x1d<<1) int contador; int main(void) { MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); PwmOut rled(LED_RED); // x y z PwmOut gled(LED_GREEN); PwmOut bled(LED_BLUE); // 4096 count/g, 2048 count/g, 1024 count/g // pc.baud(9600); //pc.format(8,SerialBase::None,1); pc.putc(); while (true) { rled = 1.0 - abs(acc.getAccX()); gled = 1.0 - abs(acc.getAccY()); bled = 1.0 - abs(acc.getAccZ()); wait(0.1); if(1024>bled) { contador++; pc.printf("PASO NUMERO%\n",contador); } else { if(1024<bled) { pc.printf("NINGUN PASO%d\n",contador); } } /* #ifndef GILBERTO #define GILBERTO #include "mbed.h" #include "MMA8451Q.h" Serial serial1 (USBTX, USBRX); MMA8451Q DigitalOut myled(LED1); Serial pc (USBTX, USBRX); MMA8451Q acc(PTE25, PTE24); PwmOut rled(LED_RED); PwmOut gled(LED_GREEN); PwmOut bled(LED_BLUE); int16_t data [3]; int cont,z; int cont1,cont,z; int main() { pc.baud(9600); // serial1.printf("%d\n",data[0]); // serial1.printf("%d\n",data[1]); pc.printf("%d\n",data[2]); pc.printf("%d\n",data[2]); // rled = 1.0 - abs(data[0]/17000.0); // rled1.0 - abs(data[0]/10.0); // gled = 1.0 - abs(data[1]/17000.0); z=bled = 1.0 - abs(data[2]/17000.0); z= 1.0 - abs(data[2]/10.0); wait(0.4); }} if(-4000>data[2]){ cont1++; pc.printf("%d\n",cont1); if(-4000<data[2]) pc.printf("%d\n",0); //}else{ // cont=0; }}} #endif */