Comprobador del la tarjeta Sensos fotodiodos

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
patxigo
Date:
Mon Dec 13 16:45:02 2021 +0000
Commit message:
V0

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 24c3bf9fb385 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Dec 13 16:45:02 2021 +0000
@@ -0,0 +1,116 @@
+#include "mbed.h"
+ 
+DigitalIn mybutton(USER_BUTTON);
+DigitalOut myled(LED1);
+ 
+ 
+Serial pc(USBTX,USBRX);
+
+DigitalIn INICIO(PA_10,PullUp);
+
+DigitalOut LED1_VERDE(PB_3);
+DigitalOut LED1_ROJO(PB_5);
+DigitalOut LED2_VERDE(PB_4);
+DigitalOut LED2_ROJO(PB_10);
+
+DigitalOut ACTIVA_DIODOS(PA_0);
+DigitalOut RESET_Q2(PA_1);
+
+
+DigitalIn Q1(PC_1);
+DigitalIn Q2(PC_0);
+
+
+int main() {
+  
+  unsigned char Falla_Q1 = 0;
+  unsigned char Falla_Q2 = 0;
+  
+  pc.baud(9600);
+  pc.printf("Hola\n");
+  
+  LED1_VERDE = 1;
+  wait(0.5);
+  LED1_VERDE = 0;
+  LED1_ROJO = 1;
+  wait(0.5);
+  LED2_VERDE = 1;
+  wait(0.5);
+  LED2_VERDE = 0;
+  LED2_ROJO = 1;
+  wait(0.5);
+
+  LED2_ROJO = 0;
+  LED1_ROJO = 0;
+  
+  LED1_VERDE = 0;
+  LED1_ROJO = 0;
+  LED2_VERDE = 0;
+  LED2_ROJO = 0;
+  ACTIVA_DIODOS = 0;
+  RESET_Q2= 1;
+  
+  while(1) {
+ 
+   if( INICIO == 1)
+   {
+//        pc.printf("NO_PUL\n");
+        LED1_VERDE = 0;
+        LED1_ROJO = 0;
+        LED2_VERDE = 0;
+        LED2_ROJO = 0;
+        ACTIVA_DIODOS = 0;
+        RESET_Q2= 1;
+        Falla_Q1 = 0;
+        Falla_Q2 = 0;
+   
+   }
+   else
+   {
+  //       pc.printf("PUL\n");
+  
+        wait_ms(50);
+        if( Q1 == 0 ) Falla_Q1 = 1;
+        if( Q2 == 0 ) Falla_Q2 = 1;
+         
+        if( (Falla_Q1 == 0 ) && (Falla_Q2 == 0) )
+        {
+            ACTIVA_DIODOS = 1;
+            wait_ms(50);
+         
+            if( Q1 == 1 ) Falla_Q1 = 1;
+            if( Q2 == 1 ) Falla_Q2 = 1;
+
+    
+            ACTIVA_DIODOS = 0;
+            wait_ms(50);
+            RESET_Q2 = 0;
+            wait_ms(50);
+            if( Q1 == 0 ) Falla_Q1 = Falla_Q2 = 1;
+            RESET_Q2 = 1;
+        }
+  
+        if( Falla_Q1 )
+        {
+             LED1_ROJO = 1;
+             LED1_VERDE = 0;
+        }
+        else
+        {
+             LED1_VERDE = 1;
+             LED1_ROJO = 0;
+        }
+        if( Falla_Q2 )
+        {
+            LED2_ROJO = 1;
+            LED2_VERDE = 0;
+        }
+        else
+        {
+            LED2_VERDE = 1;
+            LED2_ROJO = 0;
+        }
+    }  
+  }
+}
+ 
\ No newline at end of file
diff -r 000000000000 -r 24c3bf9fb385 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Dec 13 16:45:02 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file