Control Remoto para subir, detener o bajar una cortina y con la posibilidad de programar otras teclas / cada función enciende un color de led diferente / cada tecla prende o apaga la función / En el LCD se muestra la tecla presionada, y los valores de alto, bajo, distancia del bit, cero y uno logico

Dependencies:   DebouncedIn Pulse1 TextLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
jaruiz
Date:
Fri May 23 20:01:49 2014 +0000
Commit message:
Tarea6_ControlRemoto_RuizJose_PelaezSebastian

Changed in this revision

DebouncedIn.lib Show annotated file Show diff for this revision Revisions of this file
ProgramaControl.cpp Show annotated file Show diff for this revision Revisions of this file
Pulse1.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib 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 a2790441065a DebouncedIn.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DebouncedIn.lib	Fri May 23 20:01:49 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/cmorab/code/DebouncedIn/#dc1131de43e8
diff -r 000000000000 -r a2790441065a ProgramaControl.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ProgramaControl.cpp	Fri May 23 20:01:49 2014 +0000
@@ -0,0 +1,223 @@
+#include "mbed.h"
+#include <Pulse1.h>
+#include "TextLCD.h"
+#include "DebouncedIn.h"
+
+
+TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); 
+PulseInOut irda(PTD5);
+DigitalOut led(LED1); // LED ROJO
+DigitalOut led2(LED2);// LED VERDE
+DigitalOut led3(LED3); // LED AZUL
+AnalogOut Vout(PTE30); // SALIDA SONIDO
+
+int header =0; // Tiempo Cabecera
+const int head_H = 9120; //+10% OSCILOSCOPIO 
+const int head_L = 8939;//-10%  OSCILOSCOPIO 
+const int Tp=300;
+int i=0;
+const int T_alto=1630;
+const int T_bajo=533;
+const int num_bits = 24;
+int num[num_bits];
+
+
+// TECLAS PROGRAMADAS 
+
+int Tecla=0;
+const int T1=102;
+const int T2=94;
+const int T3=90;
+const int T4=82;
+const int T5=150;
+const int T6=84;
+
+
+int dato; // tiempo de cada dato que se lee
+  
+int main()
+{
+      
+      led=1;
+      led2=1;
+      led3=1;       
+while(1)
+    {
+            lcd.cls();
+            lcd.locate(0,0);
+            lcd.printf("ESPERANDO ORDEN");
+            
+            
+          
+ini1: fflush( stdin );
+      header=0;
+      header = irda.read_low_us();   
+      if (header > head_L && header < head_H) goto seguir;
+      else goto ini1;
+      
+seguir:
+
+      wait_us(4500);
+      lcd.cls();
+      Tecla=0;
+      for(i=0;i<(num_bits-1);++i)
+      { 
+        dato = irda.read_high_us(); 
+        num[i]=dato;
+        wait_us(Tp);   
+      }
+      wait(0.3); 
+ 
+      for(i=0;i<(num_bits-1);++i)
+      {  
+        
+        if(num[i] > ((T_alto+T_bajo)/2))
+            {
+                    Tecla=Tecla+ (2^(i));
+            }     
+      }
+      if(Tecla==T1)
+      {     led=!led;
+            lcd.cls();
+            lcd.printf("A: ON RIGHT"); 
+            lcd.locate(0,1);
+            lcd.printf("Codigo=%d",Tecla);
+            wait(1.5);
+            lcd.cls();
+            lcd.locate(0,0);
+            lcd.printf("HH:%d",head_H);
+            lcd.locate(8,0);
+            lcd.printf("Tby:%d",Tp);
+            lcd.locate(0,1);
+            lcd.printf("HL:%d",head_L);
+            lcd.locate(8,1);
+            lcd.printf("Nby:%d",num_bits);
+            wait(1.5);
+            Tecla=0;
+      }
+      if(Tecla==T2)
+      {
+            led2=!led2;
+            lcd.cls();
+            lcd.printf("B: STOP");  
+            lcd.locate(0,1);
+            lcd.printf("Codigo=%d",Tecla);
+            wait(1.5);
+            lcd.cls();
+            lcd.locate(0,0);
+            lcd.printf("HH:%d",head_H);
+            lcd.locate(8,0);
+            lcd.printf("Tby:%d",Tp);
+            lcd.locate(0,1);
+            lcd.printf("HL:%d",head_L);
+            lcd.locate(8,1);
+            lcd.printf("Nby:%d",num_bits);      
+            Tecla=0; 
+            wait(1.5);
+      }
+      if(Tecla==T3)
+      {
+            
+            led3=!led3;
+            lcd.cls();
+            lcd.printf("C: ON LEFT");
+            lcd.locate(0,1);
+            lcd.printf("Codigo=%d",Tecla);
+            wait(1.5);
+            lcd.cls();
+            lcd.locate(0,0);
+            lcd.printf("HH:%d",head_H);
+            lcd.locate(8,0);
+            lcd.printf("Tby:%d",Tp);
+            lcd.locate(0,1);
+            lcd.printf("HL:%d",head_L);
+            lcd.locate(8,1);
+            lcd.printf("Nby:%d",num_bits);
+            Tecla=0; 
+            wait(1.5);      
+      }
+            if(Tecla==T4)
+      {
+            
+        Vout=2.5;
+        wait(0.2);
+        Vout=0;
+            lcd.cls();
+            lcd.printf("D:Boton otra func");
+            lcd.locate(0,1);
+            lcd.printf("Codigo=%d",Tecla);
+            wait(1.5);
+            lcd.cls();
+            lcd.locate(0,0);
+            lcd.printf("HH:%d",head_H);
+            lcd.locate(8,0);
+            lcd.printf("Tby:%d",Tp);
+            lcd.locate(0,1);
+            lcd.printf("HL:%d",head_L);
+            lcd.locate(8,1);
+            lcd.printf("Nby:%d",num_bits);
+            Tecla=0; 
+            wait(1.5);      
+      }
+      
+                if(Tecla==T5)
+      {
+      Vout=2.5;
+    wait(0.07);
+    Vout=0;
+     wait(0.03);
+    Vout=2.5;
+    wait(0.07);
+    Vout=0;
+      wait(0.03);
+    Vout=2.5;
+    wait(0.07);
+    Vout=0;
+            led2=!led2;
+            lcd.cls();
+            lcd.printf("ENCENDER 1");
+            lcd.locate(0,1);
+            lcd.printf("Codigo=%d",Tecla);
+            wait(1.5);
+            lcd.cls();
+    
+      }
+      
+                      if(Tecla==T6)
+      {
+      Vout=2.5;
+    wait(0.07);
+    Vout=0;
+     wait(0.03);
+    Vout=2.5;
+    wait(0.07);
+    Vout=0;
+      
+            led3=!led3;
+            lcd.cls();
+            lcd.printf("ENCENDER 2");
+            lcd.locate(0,1);
+            lcd.printf("Codigo=%d",Tecla);
+            wait(1.5);
+            lcd.cls();
+            
+      }
+      if ((Tecla!=T3)&&(Tecla!=T2)&&(Tecla!=T1)&&(Tecla!=0)&&(Tecla!=T4)&&(Tecla!=T5)&&(Tecla!=T6)){ 
+      lcd.cls();
+      lcd.printf("SIN FUNCION");
+      lcd.locate(0,1);
+      lcd.printf("Codigo=%d",Tecla);
+      wait(2);
+      lcd.cls();
+      lcd.locate(0,0);
+      lcd.printf("HH:%d",head_H);
+      lcd.locate(8,0);
+      lcd.printf("Tby:%d",Tp);
+      lcd.locate(0,1);
+      lcd.printf("HL:%d",head_L);
+      lcd.locate(8,1);
+      lcd.printf("Nby:%d",num_bits);
+      Tecla=0; 
+      wait(1.5);}
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r a2790441065a Pulse1.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Pulse1.lib	Fri May 23 20:01:49 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/tony63/code/Pulse1/#48651f86a80c
diff -r 000000000000 -r a2790441065a TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Fri May 23 20:01:49 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
diff -r 000000000000 -r a2790441065a mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri May 23 20:01:49 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file