void IR_Receive_function()
{
unsigned i=0,k=0;
if (Ir_Over)
{
EX0=0; EX1=0; //关外部中断
if (DAT[0]==DAT[1]&&DAT[2]!=DAT[3])
{
switch (DAT[3])
{
case 0XFF: if(inbuf1[19]==‘1‘)inbuf1[19]=‘0‘;else inbuf1[19]=‘1‘;break;
case 0XFE: if(inbuf1[20]==‘1‘)inbuf1[20]=‘0‘;else inbuf1[20]=‘1‘;break;
case 0XFD: if(inbuf1[21]==‘1‘)inbuf1[21]=‘0‘;else inbuf1[21]=‘1‘;break;
case 0XFC: if(inbuf1[22]==‘1‘)inbuf1[22]=‘0‘;else inbuf1[22]=‘1‘;break;
case 0XFB: if(inbuf1[23]==‘1‘)inbuf1[23]=‘0‘;else inbuf1[23]=‘1‘;break;
case 0XFA: if(inbuf1[24]==‘1‘)inbuf1[24]=‘0‘;else inbuf1[24]=‘1‘;break;
case 0XF9: if(inbuf1[25]==‘1‘)inbuf1[25]=‘0‘;else inbuf1[25]=‘1‘;break;
case 0XF8: if(inbuf1[26]==‘1‘)inbuf1[26]=‘0‘;else inbuf1[26]=‘1‘;break;
default: break;
}
}
Ir_Over=0;
EX0=1;EX1=1; //开外部中断
}
}
一段红外处理程序,在数据缓冲区里如果有按键就取反!
方法N多