先给你传个我做的实物图片,用LCD2004显示,发射可以自编任意数据(这几天正在调红外通信)你的要求已经实现,若需要程序再CALL我:270531131@qq.com
#include
#define uchar unsigned char
#define uint unsigned int
#define c(x) (x*110592/120000)
sbit Ir_pin=P3^3;
sbit duan=P2^6;
sbit wei=P2^7;
uint temp1;
uchar code led_tao[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71};
uchar code led_sel[]={0xfe,0xfd,0xef,0xdf};
uchar led_buf[4];
char led_index;
uchar Ir_buf[4];
void time() interrupt 1 using 1
{
TL0=65536-1000;
TH0=(65536-1000)/256;
P0=0xff;
wei=1;
P0=led_sel[led_index];
wei=0;
duan=1;
P0=led_tao[led_buf[led_index]];
duan=0;
if(++led_index>3) led_index=0;
led_buf[1]=Ir_buf[2]&0xf;
led_buf[0]=(Ir_buf[2]/16)&0xf;
led_buf[3]=Ir_buf[3]&0xf;
led_buf[2]=(Ir_buf[3]/16)&0xf;
}
uint Ir_get_low()
{
TL1=0;
TH1=0;
TR1=1;
while(!Ir_pin&&(TH1&0X80)==0);
TR1=0;
return TH1*256+TL1;
}
uint Ir_get_high()
{
TL1=0;
TH1=0;
TR1=1;
while(Ir_pin&&(TH1&0X80)==0);
TR1=0;
return TH1*256+TL1;
}
void jie()
{
uint temp;
char i,j;
led_index=1;
TMOD=0X11;
TL0=65536-1000;
TH0=(65536-1000)/256;
EA=1;
ET0=1;
TR0=1;
led_buf[0]=0;
led_buf[1]=0;
led_buf[2]=0;
led_buf[3]=0;
do
{
restart:
while(Ir_pin);
temp=Ir_get_low();
if(temp
temp=Ir_get_high();
if(temp
for(i=0;i<4;i++)
for(j=0;j<8;j++)
{
temp=Ir_get_low();
if(temp
temp=Ir_get_high();
if(temp
Ir_buf[i]>>=1;
if(temp>c(1120)) Ir_buf[i]|=0x80;
temp1=Ir_buf[2];
switch(temp1)
{
case 0x00:
P1=0xff;
break;
case 0x02:
P1=0x00;
break;
case 0x04:
P1=0xfe;
break;
case 0x05:
P1=0xfc;
break;
case 0x06:
P1=0xf8;
break;
case 0x08:
P1=0xf0;
break;
case 0x09:
P1=0xe0;
break;
case 0x0a:
P1=0xc0;
break;
case 0x0c:
P1=0x80;
break;
case 0x0d:
P1=0x00;
break;
case 0x0e:
P1=0xaa;
break;
case 0x10:
P1=0x55;
break;
case 0x11:
P1=0xe7;
break;
case 0x12:
P1=0x7e;
break;
}
}
}while(1);
}
void main()
{
jie();
}