Olivia Itzel Solano
/
Contador_De_Pasos
Contador de pasos
solano.h@12:a73fdd04a291, 2016-02-15 (annotated)
- Committer:
- OlySolano
- Date:
- Mon Feb 15 00:39:58 2016 +0000
- Revision:
- 12:a73fdd04a291
- Parent:
- 9:ff57931068f4
Al parecer ya quedo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
OlySolano | 2:0feb4132c246 | 1 | #ifndef SOLANO |
OlySolano | 2:0feb4132c246 | 2 | #define SOLANO |
OlySolano | 2:0feb4132c246 | 3 | #include "mbed.h" |
OlySolano | 9:ff57931068f4 | 4 | #include "MMA8451Q.h" |
OlySolano | 9:ff57931068f4 | 5 | |
OlySolano | 9:ff57931068f4 | 6 | Serial serial1 (USBTX, USBRX); |
OlySolano | 9:ff57931068f4 | 7 | MMA8451Q acc(PTE25, PTE24); |
OlySolano | 9:ff57931068f4 | 8 | PwmOut rled(LED_RED); |
OlySolano | 9:ff57931068f4 | 9 | PwmOut gled(LED_GREEN); |
OlySolano | 9:ff57931068f4 | 10 | PwmOut bled(LED_BLUE); |
OlySolano | 9:ff57931068f4 | 11 | int16_t data [3]; |
OlySolano | 9:ff57931068f4 | 12 | |
OlySolano | 9:ff57931068f4 | 13 | int main() { |
OlySolano | 9:ff57931068f4 | 14 | serial1.baud(9600); |
OlySolano | 9:ff57931068f4 | 15 | serial1.format(8,SerialBase::None,1); |
OlySolano | 9:ff57931068f4 | 16 | serial1.putc(65); |
OlySolano | 9:ff57931068f4 | 17 | |
OlySolano | 9:ff57931068f4 | 18 | while(1) { |
OlySolano | 9:ff57931068f4 | 19 | acc.getAccAllAxis(data); |
OlySolano | 9:ff57931068f4 | 20 | |
OlySolano | 9:ff57931068f4 | 21 | //serial1.printf("%d\n",data[0]); |
OlySolano | 9:ff57931068f4 | 22 | //serial1.printf("%d\n",data[1]); |
OlySolano | 9:ff57931068f4 | 23 | serial1.printf("%d\n",data[2]); |
OlySolano | 9:ff57931068f4 | 24 | |
OlySolano | 9:ff57931068f4 | 25 | //rled = 1.0 - abs(data[0]/17000.0); |
OlySolano | 9:ff57931068f4 | 26 | //gled = 1.0 - abs(data[1]/17000.0); |
OlySolano | 9:ff57931068f4 | 27 | bled = 1.0 - abs(data[2]/17000.0); |
OlySolano | 9:ff57931068f4 | 28 | wait(0.4); |
OlySolano | 12:a73fdd04a291 | 29 | pc.printf("pasos %d\n",cont); |
OlySolano | 12:a73fdd04a291 | 30 | cont++; |
OlySolano | 12:a73fdd04a291 | 31 | rled=0; |
OlySolano | 12:a73fdd04a291 | 32 | |
OlySolano | 12:a73fdd04a291 | 33 | //if(cont >'1'){ |
OlySolano | 12:a73fdd04a291 | 34 | // cont++; |
OlySolano | 12:a73fdd04a291 | 35 | //contt= cont1+cont; |
OlySolano | 12:a73fdd04a291 | 36 | //pc.printf("paso %d\n",cont+cont1); |
OlySolano | 12:a73fdd04a291 | 37 | //wait(1.0); |
OlySolano | 12:a73fdd04a291 | 38 | //pc.printf("paso %d\n",contt); |
OlySolano | 12:a73fdd04a291 | 39 | }else{ |
OlySolano | 12:a73fdd04a291 | 40 | rled=1; |
OlySolano | 12:a73fdd04a291 | 41 | } |
OlySolano | 12:a73fdd04a291 | 42 | // if(-3500<data[2]&& data[2]>1000 ){ |
OlySolano | 12:a73fdd04a291 | 43 | // cont1++; |
OlySolano | 12:a73fdd04a291 | 44 | //contt=cont+cont1; |
OlySolano | 12:a73fdd04a291 | 45 | //pc.printf("pasito%d\n",contt); |
OlySolano | 12:a73fdd04a291 | 46 | // pc.printf("%d\n",cont1); |
OlySolano | 12:a73fdd04a291 | 47 | // rled=0; |
OlySolano | 12:a73fdd04a291 | 48 | // }else{ |
OlySolano | 12:a73fdd04a291 | 49 | // rled=1; |
OlySolano | 12:a73fdd04a291 | 50 | } |
OlySolano | 12:a73fdd04a291 | 51 | //if(1000>data[2]&& data[2]<=-3500){ |
OlySolano | 12:a73fdd04a291 | 52 | //data[2]=0; |
OlySolano | 12:a73fdd04a291 | 53 | |
OlySolano | 12:a73fdd04a291 | 54 | } |
OlySolano | 12:a73fdd04a291 | 55 | |
OlySolano | 9:ff57931068f4 | 56 | } |
OlySolano | 12:a73fdd04a291 | 57 | |
OlySolano | 9:ff57931068f4 | 58 | } |
OlySolano | 9:ff57931068f4 | 59 | |
OlySolano | 9:ff57931068f4 | 60 | |
OlySolano | 2:0feb4132c246 | 61 | |
OlySolano | 2:0feb4132c246 | 62 | |
OlySolano | 2:0feb4132c246 | 63 | |
OlySolano | 2:0feb4132c246 | 64 | #endif |