Reconocimiento de teclas, Control SONY se iluminan leds con la tecla indicada, Power, CH+, CH-

Dependencies:   Pulse1 TextLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
walterg
Date:
Thu May 22 23:41:49 2014 +0000
Commit message:
Tarea_6

Changed in this revision

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
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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Pulse1.lib	Thu May 22 23:41:49 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/tony63/code/Pulse1/#48651f86a80c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Thu May 22 23:41:49 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 22 23:41:49 2014 +0000
@@ -0,0 +1,152 @@
+// Walter Giraldo Gonzalez
+// Gregorio Velasquez Gomez
+
+#include "mbed.h"
+#include <Pulse1.h>
+#include "TextLCD.h"
+
+
+TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7#include "TextLCD.h"
+//control remoto videobeam aula
+PulseInOut irda(PTD5);// en este puerto se pone el sensor infrarrojo
+DigitalOut led(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+
+int header =2470; //tiempo de cabecera pulso abajo
+const int head_H = 2470+247; //+10% medida con osciloscopio en microsegundos
+const int head_L = 2470-247;//-10%  medida con osciloscopio
+const int Te=400;
+int i=0;
+const int T_alto=1270;//1630;//ponga su tiempo de la prueba
+const int T_bajo=667;//533;//ponga su tiempo de la prueba
+const int num_bits = 16;//ponga su numero de bits
+int num[num_bits];//cadena para almacenar todos los tiempos que conforman los bits de datos
+
+int Tecla=0;
+const int power=54;
+const int CHA=28;
+const int CHB=40;
+
+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("PRESIONE BOTON");
+          
+ini1: fflush( stdin );
+      header=0;
+      header = irda.read_low_us();    //funcion para leer un pulso de caida o bajo en header
+      if (header > head_L && header < head_H) goto seguir;//verificar que este en la tolerancia +-20%
+      else goto ini1;
+      
+seguir:
+       //leo los datos de la trama y se meten a un arreglo
+      wait_us(2417);// ES EL TIEMPO DE HEADER QUE NO SE Lee O EL ALTO 
+      //led2=0;
+      lcd.cls();
+      Tecla=0;
+      for(i=0;i<(num_bits-1);++i)
+      { // POR OSCILOSCOPIO se determina que llegan (num_bits),datos
+        dato = irda.read_low_us(); //leer un bit de datos que es pulso arriba en este control
+        num[i]=dato;
+        wait_us(Te);   
+      }
+      wait(0.3); //espero un poquito luego de leer todo el arreglo y ponerlo en pantalla 
+ 
+      for(i=0;i<(num_bits-1);++i)
+      {  
+        
+        if(num[i] > ((T_alto+T_bajo)/2))
+            {
+                    Tecla=Tecla+ (2^(i));// ecuación que me caracterizara cada tecla es un acumulado el cual podre usar para comparar
+            }
+          
+      }
+      if(Tecla==power) //Comparación de el acumulado "tecla ", con el acumulado que tiene la tecla power que corresponde a la tecla POWER 
+      {     led=!led;
+            lcd.cls();
+            lcd.printf("POWER"); 
+            lcd.locate(0,1);
+            lcd.printf("Acumulado=%d",Tecla);
+            wait(2);
+            lcd.cls();
+            lcd.locate(0,0);
+            lcd.printf("HH:%d",head_H);
+            lcd.locate(8,0);
+            lcd.printf("Tby:%d",Te);
+            lcd.locate(0,1);
+            lcd.printf("HL:%d",head_L);
+            lcd.locate(8,1);
+            lcd.printf("Nby:%d",num_bits);
+            wait(2);
+            Tecla=0;
+      }
+      if(Tecla==CHA)
+      {
+            led2=!led2;
+            lcd.cls();
+            lcd.printf("Boton CH +");  
+            lcd.locate(0,1);
+            lcd.printf("Acumulado=%d",Tecla);
+            wait(2);
+            lcd.cls();
+            lcd.locate(0,0);
+            lcd.printf("HH:%d",head_H);
+            lcd.locate(8,0);
+            lcd.printf("Tby:%d",Te);
+            lcd.locate(0,1);
+            lcd.printf("HL:%d",head_L);
+            lcd.locate(8,1);
+            lcd.printf("Nby:%d",num_bits);      
+            Tecla=0; 
+            wait(2);
+      }
+      if(Tecla==CHB)
+      {
+            
+            led3=!led3;
+            lcd.cls();
+            lcd.printf("Boton CH -");
+            lcd.locate(0,1);
+            lcd.printf("Acumulado=%d",Tecla);
+            wait(2);
+            lcd.cls();
+            lcd.locate(0,0);
+            lcd.printf("HH:%d",head_H);
+            lcd.locate(8,0);
+            lcd.printf("Tby:%d",Te);
+            lcd.locate(0,1);
+            lcd.printf("HL:%d",head_L);
+            lcd.locate(8,1);
+            lcd.printf("Nby:%d",num_bits);
+            Tecla=0; 
+            wait(2);      
+      }
+      if ((Tecla!=CHB)&&(Tecla!=CHA)&&(Tecla!=power)&&(Tecla!=0)){ 
+      lcd.cls();
+      lcd.printf("Boton incorrecto");
+      lcd.locate(0,1);
+      lcd.printf("Acumulado=%d",Tecla);
+      wait(2);
+      lcd.cls();
+      lcd.locate(0,0);
+      lcd.printf("HH:%d",head_H);
+      lcd.locate(8,0);
+      lcd.printf("Tby:%d",Te);
+      lcd.locate(0,1);
+      lcd.printf("HL:%d",head_L);
+      lcd.locate(8,1);
+      lcd.printf("Nby:%d",num_bits);
+      Tecla=0; 
+      wait(2);}
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 22 23:41:49 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/f37f3b9c9f0b
\ No newline at end of file