Funcionando

Dependencies:   HCSR04 mbed

Fork of ASEnsor by samuel lopez

Files at this revision

API Documentation at this revision

Comitter:
amozaner
Date:
Mon May 22 04:08:35 2017 +0000
Parent:
0:a620cb2d52ad
Commit message:
Dos ultrasonidos al tiempo :D UD ;

Changed in this revision

HCSR04.lib Show diff for this revision Revisions of this file
Ultrasonidosaltiemp.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r a620cb2d52ad -r 6c4e1cd50d4c HCSR04.lib
--- a/HCSR04.lib	Mon Dec 12 07:19:17 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/users/antoniolinux/code/HCSR04/#86b2086be101
diff -r a620cb2d52ad -r 6c4e1cd50d4c Ultrasonidosaltiemp.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Ultrasonidosaltiemp.lib	Mon May 22 04:08:35 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/antoniolinux/code/HCSR04/#86b2086be101
diff -r a620cb2d52ad -r 6c4e1cd50d4c main.cpp
--- a/main.cpp	Mon Dec 12 07:19:17 2016 +0000
+++ b/main.cpp	Mon May 22 04:08:35 2017 +0000
@@ -1,35 +1,48 @@
-#include "mbed.h"
+#include "mbed.h" //incluimos la libreria mbed
 #include "hcsr04.h"
-DigitalOut led(LED_RED);
-DigitalOut led1(LED_GREEN);
-DigitalOut led2(LED_BLUE);
-//D12 TRIGGER D11 ECHO
-HCSR04 sensor1(D2, D3); 
-HCSR04 sensor2(D4, D5); 
-HCSR04 sensor3(D6, D7); 
-int main() {
+
+DigitalOut RED1(LED1);
+DigitalOut GREEN1(LED2);
+DigitalOut BLUE1(LED3);
+HCSR04 sensor(PTA12, PTD4); //t,e
+HCSR04 sensor2(PTA5, PTA4); 
+
+
+
+int main()
+{
     while(1) {
-     long a = sensor1.distance(); 
-     long b = sensor2.distance(); 
-     long c = sensor3.distance(); 
-       
-if (a<10 ){
-        led= 0;
-        led1= 1;
-        led2= 1;
+        int d = sensor.distance();
+        int d2 = sensor2.distance();
+
+        if(d<=10 && d2<=10) {
+
+        RED1=0;
+        GREEN1=1;
+        BLUE1=1;
+        
+
+        
         
         }
-if (b<10 ){
-        led= 1;
-        led1= 0;
-        led2= 1;
+
+        if(d>=21 && d>=21 ) {
+
+            
+        RED1=1;
+        GREEN1=1;
+        BLUE1=0;
+             
         }
-if (c<10 ){
-        led= 1;
-        led1= 1;
-        led2= 0;
+        if((d>=11 && d<=20)&&(d2>=11 && d2<=20)) {
+
+        RED1=1;
+        GREEN1=0;
+        
+        BLUE1=1;
         }
-        
-        
+
+
+
     }
 }
\ No newline at end of file