detector de sismos

Dependencies:   MMA8451Q mbed

Revision:
0:f59de0a801a5
Child:
1:3e85b526f80f
diff -r 000000000000 -r f59de0a801a5 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Feb 19 03:45:40 2016 +0000
@@ -0,0 +1,67 @@
+#include "mbed.h"
+//Serial pc(PTE22,PTE23);
+Serial pc(USBTX, USBRX);
+
+#include "MMA8451Q.h"
+ 
+ MMA8451Q acc(PTE25, PTE24);
+ PwmOut rled(LED_RED);
+ PwmOut gled(LED_GREEN);
+ PwmOut bled(LED_BLUE);
+ int16_t dato[3];
+ int16_t x = 0;
+ int16_t y = 0;
+ int16_t z = 0;
+
+
+DigitalOut alar(D3);
+
+
+
+ 
+
+
+int main() {
+   pc.format(8,SerialBase::None,1);
+    pc.putc(65);
+    
+    
+   
+    
+   // pc.baud(9600); 
+    while(1) {
+        
+        
+        //temblor
+         acc.getAccAllAxis(dato); 
+          
+          x = dato[0] * 0.03;
+          y = dato[1] * 0.03;
+          z = dato[2] * 0.03;
+          
+       pc.printf("%d",dato[0]);
+       pc.printf(",");
+       pc.printf("%d",dato[1]); 
+       pc.printf(",");             
+       pc.printf("%d,\n",dato[2]);
+       pc.printf(","); 
+ 
+        rled = 1.0 - abs(dato[0]/16000.0);
+         gled = 1.0 - abs(dato[1]/16000.0);
+         bled = 1.0 - abs (dato[2]/16000.0);
+         wait(.3);
+
+     if(dato[1]>=900){
+         alar=1;
+          pc.printf("* TEMBLOR");
+           wait(.2);
+         }else{
+            alar=0;
+             pc.printf("* SEGURO");
+              wait(.2);
+             }
+       
+     }
+     }
+     
+     
\ No newline at end of file