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
main.cpp
- Committer:
- tony63
- Date:
- 2014-05-08
- Revision:
- 3:82bebaf2a06a
- Parent:
- 2:6a15ab0305c8
- Child:
- 4:f802aeaec9d0
File content as of revision 3:82bebaf2a06a:
#include "mbed.h"
#include <Pulse1.h>
//control remoto videobeam aula
PulseInOut irda(PTD5);// en este puerto se pone el sensor infrarrojo
Serial pc(USBTX, USBRX);
DigitalOut led(LED1);
DigitalOut led2(LED2);
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
int i=0;
const int T_alto=1630;//ponga su tiempo de la prueba
const int T_bajo=533;//ponga su tiempo de la prueba
const int num_bits = 64;//ponga su numero de bits
int num[num_bits];//cadena para almacenar todos los tiempos que conforman los bits de datos
int dato; // tiempo de cada dato que se lee
int main(){
while(1){
ini1: fflush( stdin );
header=0;
led2=1;
led=1;
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(4500);// ES EL TIEMPO DE HEADER QUE NO SE Lee O EL ALTO
led2=0;
for(i=0;i<(num_bits-1);++i){ // POR OSCILOSCOPIO se determina que llegan (num_bits),datos
dato = irda.read_high_us(); //leer un bit de datos que es pulso arriba en este control
num[i]=dato;
wait_us(300);
}
wait(0.5); //espero un poquito luego de leer todo el arreglo y ponerlo en pantalla
pc.printf(",%d",header);
for(i=0;i<(num_bits-1);++i){
pc.printf(",%d",num[i]);
}
wait(0.1); //espero e imprimo en binario
pc.printf("\n\n");
for(i=0;i<(num_bits-1);++i){
if(num[i] > ((T_alto+T_bajo)/2)) pc.printf("1");
else pc.printf("0");
}
}
}
