哪位大侠帮忙看看 为什么我这个红外解码程序就是不行咧
时间:10-02
整理:3721RD
点击:
#include<reg51.h>
#define wei P0
#define duan P1
sbit ird=P3^2;
signed int timelong;
unsigned int z;
unsigned char quke,b,k,yonghuma_l,yonghuma_h,anjianma_z,anjianma_f;
unsigned char code zifuku[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E};
void delay(unsigned int z){
unsigned int x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);}
void main(){
IT0=1;
EX0=1;
EA=1;
TMOD=1;
TH0=0;
TL0=0;
wei=0x00;
duan=0xff;
quke=0x00;
b=0;
while(1){
while(ird); //判断接收头是否有输入
while((timelong-2000)&&(2500-timelong)<1); //检测是否引导码到来
for(k=32;k>0;k--){
while(ird==0); // 让循环跟中断同步进行 并且防止
while(ird==1); // 引导码的timelong代入
while(ird==0); // 下面的for循环
quke=quke>>1;
if((timelong-2000)&&(2500-timelong)>0){ //解码1
quke=quke|0x80;
}
if((timelong-850)&&(1375-timelong)>0) { //解码0
quke=quke|0x00;
}
if(k==24){yonghuma_l=quke;}
if(k==16){yonghuma_h=quke;}
if(k==8){anjianma_z=quke;}
if(k==0){anjianma_f=quke;}
}
while((timelong-20000)<0){ //如果没有引导码 就一直显示解码值
wei=0x80;
duan=zifuku[anjianma_z/16];
delay(1);
duan=0xff;
wei=0x40;
duan=zifuku[anjianma_z%16];
delay(1);
duan=0xff;
}
}
}
void zd ()interrupt 0{
unsigned char a;
if(a>0){
TR0=0;
timelong=TH0*256+TL0;
TH0=0;
TL0=0;
TR0=1;
}
else{TR0=1;
a++;
}
}
#define wei P0
#define duan P1
sbit ird=P3^2;
signed int timelong;
unsigned int z;
unsigned char quke,b,k,yonghuma_l,yonghuma_h,anjianma_z,anjianma_f;
unsigned char code zifuku[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E};
void delay(unsigned int z){
unsigned int x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);}
void main(){
IT0=1;
EX0=1;
EA=1;
TMOD=1;
TH0=0;
TL0=0;
wei=0x00;
duan=0xff;
quke=0x00;
b=0;
while(1){
while(ird); //判断接收头是否有输入
while((timelong-2000)&&(2500-timelong)<1); //检测是否引导码到来
for(k=32;k>0;k--){
while(ird==0); // 让循环跟中断同步进行 并且防止
while(ird==1); // 引导码的timelong代入
while(ird==0); // 下面的for循环
quke=quke>>1;
if((timelong-2000)&&(2500-timelong)>0){ //解码1
quke=quke|0x80;
}
if((timelong-850)&&(1375-timelong)>0) { //解码0
quke=quke|0x00;
}
if(k==24){yonghuma_l=quke;}
if(k==16){yonghuma_h=quke;}
if(k==8){anjianma_z=quke;}
if(k==0){anjianma_f=quke;}
}
while((timelong-20000)<0){ //如果没有引导码 就一直显示解码值
wei=0x80;
duan=zifuku[anjianma_z/16];
delay(1);
duan=0xff;
wei=0x40;
duan=zifuku[anjianma_z%16];
delay(1);
duan=0xff;
}
}
}
void zd ()interrupt 0{
unsigned char a;
if(a>0){
TR0=0;
timelong=TH0*256+TL0;
TH0=0;
TL0=0;
TR0=1;
}
else{TR0=1;
a++;
}
}
调试了好几天还是没头绪 本人小白 哪位大侠会的就麻烦帮忙看看啦 谢谢
唉 没热心肠的大虾帮助 但是经过连续几夜奋斗 还是完美搞定啦 。
哥地贴,自己看吧,程序自己改
NEC 红外解码