el prollecto trata del detector de las vibraciones de un motor alejandro mejia garcia jorge arturo juarez ornelas

Dependencies:   MMA8451Q mbed

Committer:
Jamg
Date:
Fri Feb 12 13:41:02 2016 +0000
Revision:
14:93d715bd49a7
Parent:
13:0d56aff123d4
Child:
15:29157e15b78e
Revisar

Who changed what in which revision?

UserRevisionLine numberNew 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 14:93d715bd49a7 11 int16_t y = 0;
Jajo 0:f4790997ab47 12 int16_t z = 0;
Jajo 0:f4790997ab47 13
Jajo 0:f4790997ab47 14 int main() {
Jamg 14:93d715bd49a7 15 while(1) {
Jamg 14:93d715bd49a7 16
Jajo 0:f4790997ab47 17 acc.getAccAllAxis(dato);
Jajo 0:f4790997ab47 18 x = dato[0] * 0.03;
Jajo 0:f4790997ab47 19 y = dato[1] * 0.03;
Jajo 0:f4790997ab47 20 z = dato[2] * 0.03;
Jajo 0:f4790997ab47 21
Jajo 13:0d56aff123d4 22 if(dato[0]<=-200){
Jajo 0:f4790997ab47 23 rled=0;
Jajo 13:0d56aff123d4 24 wait(.2);
Jajo 0:f4790997ab47 25 rled=1;
Jajo 0:f4790997ab47 26 }else{
Jajo 0:f4790997ab47 27 bled=1;
Jajo 0:f4790997ab47 28 gled=0;
Jajo 13:0d56aff123d4 29 wait(.2);
Jajo 0:f4790997ab47 30 gled=1;
Jajo 0:f4790997ab47 31 }
Jajo 0:f4790997ab47 32
Jajo 13:0d56aff123d4 33
Jajo 13:0d56aff123d4 34 if(dato[1]>=350){
Jajo 13:0d56aff123d4 35 bled=1;
Jajo 13:0d56aff123d4 36 rled=0;
Jajo 13:0d56aff123d4 37
Jajo 13:0d56aff123d4 38 wait(.2);
Jajo 13:0d56aff123d4 39
Jajo 13:0d56aff123d4 40 rled=1;
Jajo 13:0d56aff123d4 41 }else{
Jajo 13:0d56aff123d4 42 bled=1;
Jajo 13:0d56aff123d4 43 gled=0;
Jajo 13:0d56aff123d4 44
Jajo 13:0d56aff123d4 45 wait(.2);
Jajo 13:0d56aff123d4 46 gled=1;
Jajo 13:0d56aff123d4 47 }
Jajo 0:f4790997ab47 48
Jajo 13:0d56aff123d4 49 if(dato[2]<=16200){
Jajo 13:0d56aff123d4 50 bled=1;
Jajo 13:0d56aff123d4 51 rled=0;
Jajo 13:0d56aff123d4 52
Jajo 13:0d56aff123d4 53 wait(.2);
Jajo 13:0d56aff123d4 54
Jajo 13:0d56aff123d4 55 rled=1;
Jajo 13:0d56aff123d4 56 }else{
Jajo 13:0d56aff123d4 57 bled=1;
Jajo 13:0d56aff123d4 58 gled=0;
Jajo 13:0d56aff123d4 59
Jajo 13:0d56aff123d4 60 wait(.2);
Jajo 13:0d56aff123d4 61 gled=1;
Jamg 14:93d715bd49a7 62 } }
Jajo 0:f4790997ab47 63 }