Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Pulse1 TextLCD mbed
Fork of irda_V_aula by
Diff: main.cpp
- Revision:
- 5:b43bc33f5002
- Parent:
- 4:f802aeaec9d0
diff -r f802aeaec9d0 -r b43bc33f5002 main.cpp
--- a/main.cpp Wed May 14 16:26:50 2014 +0000
+++ b/main.cpp Mon Apr 27 22:48:42 2015 +0000
@@ -1,5 +1,5 @@
-// Santiago Lopez Restrepo
-// Diego Fernando Carvajal Castrillon
+// Luisa Fernanda Perez Luna
+// Carlos Mario Florez Ramirez
#include "mbed.h"
#include <Pulse1.h>
@@ -7,33 +7,36 @@
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
+PulseInOut irda(PTD5);//sensor infrarrojo
DigitalOut led(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
int header =0; //tiempo de cabecera pulso abajo
-const int head_H = 9120; //+10% medida con osciloscopio en microsegundos
-const int head_L = 8939;//-10% medida con osciloscopio
+const int head_H = 9000; //+10% medida con osciloscopio en microsegundos, cabecera alta
+const int head_L = 4600;//-10% medida con osciloscopio, cabecera baja
const int Tp=300;
int i=0;
-const int T_alto=1570;//1630;//ponga su tiempo de la prueba
-const int T_bajo=467;//533;//ponga su tiempo de la prueba
+const int T_alto=1670;//1630;//ponga su tiempo de 1 logico
+const int T_bajo=533;//533;//ponga su tiempo de 0 logico
const int num_bits = 24;//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 N1=96;
-const int N2=117;
-const int N3=109;
+const int N1=133;//tecla1
+const int N2=139;//tecla4
+const int N3=83;//tecla7
+const int N4=121;//tecla2
+const int N5=152;//tecla5
+const int N6=88;//tecla8
+const int N7=134;//tecla3
int dato; // tiempo de cada dato que se lee
int main()
{
- led=1;
+ led=1; //leds apagados
led2=1;
led3=1;
while(1)
@@ -43,7 +46,7 @@
lcd.cls();
lcd.locate(0,0);
- lcd.printf("PRESIONE TECLA");
+ lcd.printf("PRESIONE BOTON");
ini1: fflush( stdin );
header=0;
@@ -75,12 +78,133 @@
}
if(Tecla==N1)
- { led=!led;
+ {
+ led3=1;
+ led2=1;
+ led=!led;
+ lcd.cls();
+ lcd.printf("PRESIONASTE 1");
+ lcd.locate(0,1);
+ lcd.printf("Codigo=%d",Tecla);
+ wait(1);
lcd.cls();
- lcd.printf("PRESIONASTE 1");
+ 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(2);
+ //led3=1;
+ }
+
+ if(Tecla==N2)
+ {
+ led=1;
+ led3=1;
+ led2=!led2;
+ lcd.cls();
+ lcd.printf("PRESIONASTE 4");
+ lcd.locate(0,1);
+ lcd.printf("Codigo=%d",Tecla);
+ wait(1);
+ 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(2);
+ //led3=1;
+ } if(Tecla==N3)
+ {
+ led=1;
+ led2=1;
+ led3=!led3;
+ lcd.cls();
+ lcd.printf("PRESIONASTE 7");
lcd.locate(0,1);
lcd.printf("Codigo=%d",Tecla);
+ wait(1);
+ 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(2);
+ //led3=1;
+ }
+ if(Tecla==N4)
+ {
+ led=0;
+ led2=0;
+ led3=1;
+ lcd.cls();
+ lcd.printf("PRESIONASTE 2");
+ lcd.locate(0,1);
+ lcd.printf("Codigo=%d",Tecla);
+ wait(1);
+ 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(2);
+ led=1;
+ led2=1;
+
+ }
+
+ if(Tecla==N5)
+ {
+ led=1;
+ led2=0;
+ led3=0;
+ lcd.cls();
+ lcd.printf("PRESIONASTE 5");
+ lcd.locate(0,1);
+ lcd.printf("Codigo=%d",Tecla);
+ wait(1);
+ 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(2);
+ led2=1;
+ led3=1;
+ }
+ if(Tecla==N6)
+ { led=0;
+ led2=1;
+ led3=0;
+ lcd.cls();
+ lcd.printf("PRESIONASTE 8");
+ lcd.locate(0,1);
+ lcd.printf("Codigo=%d",Tecla);
+ wait(1);
lcd.cls();
lcd.locate(0,0);
lcd.printf("HH:%d",head_H);
@@ -92,36 +216,18 @@
lcd.printf("Nby:%d",num_bits);
wait(2);
Tecla=0;
+ led=1;
+ led3=1;
}
- if(Tecla==N2)
- {
- led2=!led2;
+ if(Tecla==N7)
+ { led=0;
+ led2=0;
+ led3=0;
lcd.cls();
- lcd.printf("PRESIONASTE 2");
+ lcd.printf("PRESIONASTE 3");
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(2);
- }
- if(Tecla==N3)
- {
-
- led3=!led3;
- lcd.cls();
- lcd.printf("PRESIONASTE 3");
- lcd.locate(0,1);
- lcd.printf("Codigo=%d",Tecla);
- wait(2);
+ wait(1);
lcd.cls();
lcd.locate(0,0);
lcd.printf("HH:%d",head_H);
@@ -131,15 +237,19 @@
lcd.printf("HL:%d",head_L);
lcd.locate(8,1);
lcd.printf("Nby:%d",num_bits);
- Tecla=0;
- wait(2);
+ wait(2);
+ Tecla=1;
+ led=1;
+ led2=1;
+ led3=1;
}
+
if ((Tecla!=N3)&&(Tecla!=N2)&&(Tecla!=N1)&&(Tecla!=0)){
lcd.cls();
lcd.printf("TECLA INCORRECTA");
lcd.locate(0,1);
lcd.printf("Codigo=%d",Tecla);
- wait(2);
+ wait(1);
lcd.cls();
lcd.locate(0,0);
lcd.printf("HH:%d",head_H);
