cebrax
Newbie level 6
Hey all,
I want to make a self learning infrared transceiver that learns every infrared code.
I know, it sounds like I want to step too many ladders.. But is possible right?
I am using Mikroelektronika mikroC PRO for PIC compiler.
Here is my code so far, but I am totally lost.
Any help?
I want to make a self learning infrared transceiver that learns every infrared code.
I know, it sounds like I want to step too many ladders.. But is possible right?
I am using Mikroelektronika mikroC PRO for PIC compiler.
Here is my code so far, but I am totally lost.
Any help?
Code:
bit infrared,buffer,change,j;
unsigned char measure=0,ref1=0,timepassed;
volatile unsigned char i=0;
void interrupt()
{
if(INTCON.T0IF)
{
measure++;
TMR0=0;
INTCON.T0IF=0;
}
}
void main(){
unsigned char measuretxt[7];
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
PORTB = 0;
PORTC = 0;
PORTD = 0;
TRISB = 0;
TRISC = 0;
TRISD = 0x01;
OPTION_REG=0x80;
TMR0=0;
INTCON.T0IE=1;
INTCON.GIE=1;
j=0;
buffer=0;
while(1)
{
infrared=~PORTD.F0;
if(buffer==infrared) change=0;
else
{
change=1;
buffer=infrared;
}
/*
|-----| |-----| |-----|
| | | | | |
____| |____| |____| |____
*/
if(change)
{
if(!j){ ref1=measure; j=1; }
else{ timepassed=measure-ref1;
ref1=measure;
}
EEPROM_Write(0x00+i,timepassed);
i++;
}
}
}