收发同文件:
#include //接收数据
unsigned char a;
unsigned char l,h,key;
void delay(unsigned t)
{
while(t--);
}
void main()
{
TMOD=0X20;
TH1=0XFD;
TL1=0XFD;
TR1=1;
SM0=0;
SM1=1;
REN=1;
EA=1;
ES=1;
P1=0xff;
while(1)
{
P2=0xf0;
l=P2;
l=l&0xf0;
if(l!=0xf0)
{
delay(200);
if(l!=0xf0)
{
l=P2&0xf0;
l=l|0x0f;
P2=l;
h=P2;
h=h&0x0f;
l=l&0xf0;
key=l+h;
}
}
switch(key)
{
case 0xee:SBUF=0xc0;break;
case 0xde:SBUF=0xf9;break;
case 0xbe:SBUF=0xa4;break;
case 0x7e:SBUF=0xb0;break;
case 0xed:SBUF=0x99;break;
case 0xdd:SBUF=0x92;break;
case 0xbd:SBUF=0x82;break;
case 0x7d:SBUF=0xf8;break;
case 0xeb:SBUF=0x80;break;
case 0xdb:SBUF=0x90;break;
case 0xbb:SBUF=0x88;break;
case 0x7b:SBUF=0x83;break;
case 0xe7:SBUF=0xc6;break;
case 0xd7:SBUF=0xa1;break;
case 0xb7:SBUF=0x86;break;
case 0x77:SBUF=0x8e;break;
}
}
}
void usbchuan() interrupt 4
{
a=SBUF;
P1=a;
RI=0;
}
c:
阅读(396) | 评论(0) | 转发(0) |