Tarea6-Versión. Usando un receptor infrarrojo y un control remoto mostrar los tiempos en pantalla de cabecera en pantalla.
Dependencies: DebouncedIn Pulse1 TextLCD mbed
Revision 0:7af58844bc21, committed 2014-06-18
- Comitter:
- juniorACA
- Date:
- Wed Jun 18 17:44:49 2014 +0000
- Commit message:
- Tarea 6- Versi?n 1
Changed in this revision
diff -r 000000000000 -r 7af58844bc21 DebouncedIn.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DebouncedIn.lib Wed Jun 18 17:44:49 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/cmorab/code/DebouncedIn/#dc1131de43e8
diff -r 000000000000 -r 7af58844bc21 Pulse1.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Pulse1.lib Wed Jun 18 17:44:49 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/tony63/code/Pulse1/#48651f86a80c
diff -r 000000000000 -r 7af58844bc21 TextLCD.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Wed Jun 18 17:44:49 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
diff -r 000000000000 -r 7af58844bc21 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jun 18 17:44:49 2014 +0000 @@ -0,0 +1,186 @@ +#include "mbed.h" +#include <Pulse1.h> +#include "TextLCD.h" +#include "DebouncedIn.h" + +TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); +PulseInOut irda(PTD5); +DigitalOut led1(LED3); //Salida Led Azul +DigitalOut led2(LED2); //Salida Led Verde +DigitalOut led3(LED1); // Salida Led Rojo +PwmOut sonido(PTA12); // Salida sonido +const int num_bits = 25; +int header =0; //Tiempo Cabecera +const int head_L = 4400; // Tiempo de Cabecere alto +const int head_H = 4600; // Tiempo de Cabacera bajo +const int Tp=300; +const int T_bajo=470; +const int T_alto=1630; +int num[num_bits]; +int i=0; +//Programación de teclas +int Tecla=0; +const int T1=10;// +const int T2=28; +const int T3=44; + +int dato; +float Dd=10; +float pp=30; +float Fi; + +int main() +{ + led1=1; + led2=1; + led3=1; +while(1) + { + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Presionar Boton"); + + + +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(3000); + 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.5); + + for(i=0;i<(num_bits-1);++i) + { + + if(num[i] > ((T_alto+T_bajo)/2)) + { + Tecla=Tecla+ (2^(i)); + } + } + if(Tecla==T1) + + { Fi=(Dd)*100; + pp=(1/Fi); + sonido.period(pp); + sonido.write(0.1); + wait(0.1); + sonido.write(0); + wait(0.1); + led1=!led1; + lcd.cls(); + lcd.locate(4,0); + lcd.printf("Boton 1"); + lcd.locate(4,1); + lcd.printf("Codigo=%d",Tecla); + wait(3); + lcd.cls(); + lcd.locate(4,0); + lcd.printf("HL:%d",head_L); + lcd.locate(4,1); + lcd.printf("HH:%d",head_H); + wait(3); + lcd.cls(); + lcd.locate(4,0); + lcd.printf("Tbi:%d",Tp); + lcd.locate(4,1); + lcd.printf("Nbi:%d",num_bits); + wait(3); + Tecla=0; + } + if(Tecla==T2) + { Fi=(Dd)*100; + pp=(1/Fi); + sonido.period(pp); + sonido.write(0.1); + wait(0.1); + sonido.write(0); + wait(0.1); + led2=!led2; + lcd.cls(); + lcd.locate(4,0); + lcd.printf("Boton 2"); + lcd.locate(4,1); + lcd.printf("Codigo=%d",Tecla); + wait(3); + lcd.cls(); + lcd.locate(4,0); + lcd.printf("HL:%d",head_L); + lcd.locate(4,1); + lcd.printf("HH:%d",head_H); + wait(3); + lcd.cls(); + lcd.locate(4,0); + lcd.printf("Tbi:%d",Tp); + lcd.locate(4,1); + lcd.printf("Nbi:%d",num_bits); + wait(3); + Tecla=0; + + } + if(Tecla==T3) + { + Fi=(Dd)*100; + pp=(1/Fi); + sonido.period(pp); + sonido.write(0.1); + wait(0.1); + sonido.write(0); + wait(0.1); + led3=!led3; + lcd.cls(); + lcd.locate(4,0); + lcd.printf("Boton 6"); + lcd.locate(4,1); + lcd.printf("Codigo=%d",Tecla); + wait(3); + lcd.cls(); + lcd.locate(4,0); + lcd.printf("HL:%d",head_L); + lcd.locate(4,1); + lcd.printf("HH:%d",head_H); + wait(3); + lcd.cls(); + lcd.locate(4,0); + lcd.printf("Tbi:%d",Tp); + lcd.locate(4,1); + lcd.printf("Nbi:%d",num_bits); + wait(3); + Tecla=0; + + } + + if ((Tecla!=T3)&&(Tecla!=T2)&&(Tecla!=T1)&&(Tecla!=0)){ + lcd.cls(); + lcd.locate(4,0); + lcd.printf("Boton no Valido"); + lcd.locate(4,1); + lcd.printf("Codigo=%d",Tecla); + wait(3); + lcd.cls(); + lcd.locate(4,0); + lcd.printf("HL:%d",head_L); + lcd.locate(4,1); + lcd.printf("HH:%d",head_H); + wait(3); + lcd.cls(); + lcd.locate(4,0); + lcd.printf("Tbi:%d",Tp); + lcd.locate(4,1); + lcd.printf("Nbi:%d",num_bits); + wait(3); + Tecla=0; + } + } +} \ No newline at end of file
diff -r 000000000000 -r 7af58844bc21 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Jun 18 17:44:49 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/0b3ab51c8877 \ No newline at end of file