el prollecto trata del detector de las vibraciones de un motor alejandro mejia garcia jorge arturo juarez ornelas
main.cpp@4:b4ff62c91888, 2016-02-10 (annotated)
- Committer:
- Jamg
- Date:
- Wed Feb 10 18:58:18 2016 +0000
- Revision:
- 4:b4ff62c91888
- Parent:
- 3:520a628eda11
- Child:
- 5:943404b2e562
cambio 3;
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; |
Jamg | 4:b4ff62c91888 | 11 | int16_t y = 0; //hola hola hola |
Jajo | 0:f4790997ab47 | 12 | int16_t z = 0; |
Jajo | 0:f4790997ab47 | 13 | |
Jajo | 0:f4790997ab47 | 14 | int main() { |
Jajo | 0:f4790997ab47 | 15 | |
Jajo | 0:f4790997ab47 | 16 | |
Jajo | 0:f4790997ab47 | 17 | |
Jajo | 0:f4790997ab47 | 18 | |
Jajo | 0:f4790997ab47 | 19 | while(1) { |
Jajo | 0:f4790997ab47 | 20 | |
Jajo | 0:f4790997ab47 | 21 | |
Jajo | 0:f4790997ab47 | 22 | //temblor |
Jajo | 0:f4790997ab47 | 23 | acc.getAccAllAxis(dato); |
Jajo | 0:f4790997ab47 | 24 | |
Jajo | 0:f4790997ab47 | 25 | x = dato[0] * 0.03; |
Jajo | 0:f4790997ab47 | 26 | y = dato[1] * 0.03; |
Jajo | 0:f4790997ab47 | 27 | z = dato[2] * 0.03; |
Jajo | 0:f4790997ab47 | 28 | |
Jajo | 0:f4790997ab47 | 29 | // gir.printf("%d",dato[0]); |
Jajo | 0:f4790997ab47 | 30 | //gir.printf(","); |
Jajo | 0:f4790997ab47 | 31 | // gir.printf("%d",dato[1]); |
Jajo | 0:f4790997ab47 | 32 | // gir.printf(","); |
Jajo | 0:f4790997ab47 | 33 | //gir.printf("%d,\n",dato[2]); |
Jajo | 0:f4790997ab47 | 34 | // gir.printf(","); |
Jajo | 0:f4790997ab47 | 35 | |
Jajo | 0:f4790997ab47 | 36 | // rled = 1.0 - abs(dato[0]/16000.0); |
Jajo | 0:f4790997ab47 | 37 | // gled = 1.0 - abs(dato[1]/16000.0); |
Jajo | 0:f4790997ab47 | 38 | //bled = 1.0 - abs (dato[2]/16000.0); |
Jajo | 0:f4790997ab47 | 39 | // wait(.3); |
Jajo | 0:f4790997ab47 | 40 | |
Jajo | 0:f4790997ab47 | 41 | if(dato[1]>=900){ |
Jajo | 0:f4790997ab47 | 42 | bled=1; |
Jajo | 0:f4790997ab47 | 43 | rled=0; |
Jajo | 0:f4790997ab47 | 44 | //alar=1; |
Jajo | 0:f4790997ab47 | 45 | //pc.printf("* TEMBLOR"); |
Jajo | 0:f4790997ab47 | 46 | wait(.5); |
Jajo | 0:f4790997ab47 | 47 | |
Jajo | 0:f4790997ab47 | 48 | rled=1; |
Jajo | 0:f4790997ab47 | 49 | }else{ |
Jajo | 0:f4790997ab47 | 50 | bled=1; |
Jajo | 0:f4790997ab47 | 51 | gled=0; |
Jajo | 0:f4790997ab47 | 52 | // alar=0; |
Jajo | 0:f4790997ab47 | 53 | //pc.printf("* SEGURO"); |
Jajo | 0:f4790997ab47 | 54 | wait(.5); |
Jajo | 0:f4790997ab47 | 55 | gled=1; |
Jajo | 0:f4790997ab47 | 56 | } |
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 | } |