el prollecto trata del detector de las vibraciones de un motor alejandro mejia garcia jorge arturo juarez ornelas
main.cpp@7:88b706429195, 2016-02-10 (annotated)
- Committer:
- Jajo
- Date:
- Wed Feb 10 19:14:33 2016 +0000
- Revision:
- 7:88b706429195
- Parent:
- 6:a00162528133
- Parent:
- 2:f671e524d19c
- Child:
- 8:91b272fd75d8
FINAL
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jajo | 0:f4790997ab47 | 1 | #include "mbed.h" |
Jajo | 0:f4790997ab47 | 2 | |
Jajo | 0:f4790997ab47 | 3 | #include "MMA8451Q.h" |
Jajo | 0:f4790997ab47 | 4 | |
Jajo | 0:f4790997ab47 | 5 | MMA8451Q acc(PTE25, PTE24); |
Jajo | 0:f4790997ab47 | 6 | PwmOut rled(LED_RED); |
Jajo | 0:f4790997ab47 | 7 | PwmOut gled(LED_GREEN); |
Jajo | 0:f4790997ab47 | 8 | PwmOut bled(LED_BLUE); |
Jajo | 0:f4790997ab47 | 9 | int16_t dato[3]; |
Jajo | 0:f4790997ab47 | 10 | int16_t x = 0; |
Jajo | 7:88b706429195 | 11 | int16_t y = 0; //hola YAAAAAAAAAAAAAAUUUUUUUUUUUUUUUUUUUUUUU |
Jamg | 5:943404b2e562 | 12 | |
Jajo | 0:f4790997ab47 | 13 | int16_t z = 0; |
Jajo | 0:f4790997ab47 | 14 | |
Jajo | 0:f4790997ab47 | 15 | int main() { |
Jajo | 0:f4790997ab47 | 16 | |
Jajo | 0:f4790997ab47 | 17 | |
Jajo | 0:f4790997ab47 | 18 | |
Jajo | 0:f4790997ab47 | 19 | |
Jajo | 0:f4790997ab47 | 20 | while(1) { |
Jajo | 0:f4790997ab47 | 21 | |
Jajo | 0:f4790997ab47 | 22 | |
Jajo | 0:f4790997ab47 | 23 | //temblor |
Jajo | 0:f4790997ab47 | 24 | acc.getAccAllAxis(dato); |
Jajo | 0:f4790997ab47 | 25 | |
Jajo | 0:f4790997ab47 | 26 | x = dato[0] * 0.03; |
Jajo | 0:f4790997ab47 | 27 | y = dato[1] * 0.03; |
Jajo | 0:f4790997ab47 | 28 | z = dato[2] * 0.03; |
Jajo | 0:f4790997ab47 | 29 | |
Jajo | 0:f4790997ab47 | 30 | // gir.printf("%d",dato[0]); |
Jajo | 0:f4790997ab47 | 31 | //gir.printf(","); |
Jajo | 0:f4790997ab47 | 32 | // gir.printf("%d",dato[1]); |
Jajo | 0:f4790997ab47 | 33 | // gir.printf(","); |
Jajo | 0:f4790997ab47 | 34 | //gir.printf("%d,\n",dato[2]); |
Jajo | 0:f4790997ab47 | 35 | // gir.printf(","); |
Jajo | 0:f4790997ab47 | 36 | |
Jajo | 0:f4790997ab47 | 37 | // rled = 1.0 - abs(dato[0]/16000.0); |
Jajo | 0:f4790997ab47 | 38 | // gled = 1.0 - abs(dato[1]/16000.0); |
Jajo | 0:f4790997ab47 | 39 | //bled = 1.0 - abs (dato[2]/16000.0); |
Jajo | 0:f4790997ab47 | 40 | // wait(.3); |
Jajo | 0:f4790997ab47 | 41 | |
Jajo | 0:f4790997ab47 | 42 | if(dato[1]>=900){ |
Jajo | 0:f4790997ab47 | 43 | bled=1; |
Jajo | 0:f4790997ab47 | 44 | rled=0; |
Jajo | 0:f4790997ab47 | 45 | //alar=1; |
Jajo | 0:f4790997ab47 | 46 | //pc.printf("* TEMBLOR"); |
Jajo | 0:f4790997ab47 | 47 | wait(.5); |
Jajo | 0:f4790997ab47 | 48 | |
Jajo | 0:f4790997ab47 | 49 | rled=1; |
Jajo | 0:f4790997ab47 | 50 | }else{ |
Jajo | 0:f4790997ab47 | 51 | bled=1; |
Jajo | 0:f4790997ab47 | 52 | gled=0; |
Jajo | 0:f4790997ab47 | 53 | // alar=0; |
Jajo | 0:f4790997ab47 | 54 | //pc.printf("* SEGURO"); |
Jajo | 0:f4790997ab47 | 55 | wait(.5); |
Jajo | 0:f4790997ab47 | 56 | gled=1; |
Jajo | 0:f4790997ab47 | 57 | } |
Jajo | 0:f4790997ab47 | 58 | |
Jajo | 0:f4790997ab47 | 59 | |
Jajo | 0:f4790997ab47 | 60 | |
Jajo | 0:f4790997ab47 | 61 | |
Jajo | 0:f4790997ab47 | 62 | |
Jajo | 0:f4790997ab47 | 63 | |
Jajo | 0:f4790997ab47 | 64 | } |
Jajo | 0:f4790997ab47 | 65 | } |
Jamg | 2:f671e524d19c | 66 | //Hola// |