发送程序/************************************************/
void delayms(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
/***********************************************/
void send(uchar keynum)
{
SBUF=keynum;
while(!TI);
TI=0;
}
void keyscan()
{
uint temp,key;
P1=0xff;
temp=P1;
switch(temp)
{
case 0x7f: key='U' ;break;
case 0xbf: key='D';break;
case 0xdf: key='L';break;
case 0xef: key='R';break;
case 0xf7: key='Y';break;
case 0xfb: key='J';break;
case 0xfd: key='M';break;
case 0xfe: key='N';break;
default :key=0;
}
send(key);
}
/**********************************************************/
void main()
{
TMOD=0x20;
TH1=0xfd;
TL1=0xfd;
TR1=1;
SM0=0;
SM1=1;
EA=1;
ES=1;
while(1)
{power=0;
keyscan();
}
}
=================================================================
|