//宏定义
#define uchar unsigned char
#define uint unsigned int
//包含头文件
#include <reg51.h>
#define Imax 14000 //此处为晶振为11.0592时的取值,
#define Imin 8000 //如用其它频率的晶振时,
#define Inum1 1450 //要改变相应的取值。
#define Inum2 700
#define Inum3 3000
unsigned char Im[4]={0x00,0x00,0x00,0x00};
//全局变量
uchar f,j,w;
unsigned long m,Tc;
unsigned char IrOK;
uchar code a_1[]={0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xc0,
0xe0,0xf0,0xf8,0xfc,0xfe,0xff
};
uchar code a_2[]={
0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xc0,
0xe0,0xf0,0xf8,0xfc,0xfe,0xff
};
uchar code a_3[]={
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x00,0x03,
0x07,0x0f,0x1f,0x3f,0x7f,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff
};
uchar code a_4[]={
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xfe,0xfc,0xec,0xcc,0x8c,0x0c,0x0c,0x0c,
0x8c,0xcc,0xec,0xfc,0xfe,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,
};
uchar code b[]={
0xff,0x00,0x7f,0x80,0x00,0xff,0x0c,0xff
};
uchar code b_1[]={0x00,0xff
};
uchar code b_2[]={0xff,0x00
};
uchar code b_3[]={0x01,0xfe
};
uchar code b_4[]={0xff,0x0c
};
uchar code c_1[]={0x00,0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,
0xfc,0xf8,0xf0,0xe0,0xc0,0x80
};
uchar code c_2[]={
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00,0x80,
0xc0,0xe0,0xf8,0xfc,0xfe,0xff
};
uchar code c_3[]={
0xff,0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,
0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};
uchar code c_4[]={
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0x7f,0x3f,0x1f,0x0f,0x0d,0x0c,0x0c,
0x0c,0x8c,0xcc,0xec,0xfc,0xfe,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};
uchar code d_1[]={0x00,0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,
0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00
};
uchar code d_2[]={
0x00,0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,
0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00
};
uchar code d_3[]={
0xff,0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x00,
0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff
};
uchar code d_4[]={
0xff,0xfe,0xfc,0xec,0xcc,0x8c,0x0c,0x0c,
0x0c,0x8c,0xcc,0xec,0xfc,0xfe,0xff
};
uchar code e[]={0xaa,0x55,0xae,0x5d};
uchar code f_1[]={0x00,0xff};
uchar code f_2[]={0x00,0xff};
uchar code f_3[]={0xff,0x00};
uchar code f_4[]={0xff,0x0c};
int i;
uchar flag_1,flag;
void delay(uint z) //延时函数
{
uint x,y;
for(x=z;x>0;x--)
for(y=440;y>0;y--);
}
void zhongduan()interrupt 0/*调节花样*/
{
flag++;
if(flag==11)
flag=1;
}
void intersvr1(void) interrupt 2 using 1
{
TR0=1;
Tc=TH0*256+TL0;//提取中断时间间隔时长
TH0=0;
TL0=0; //定时中断重新置零
if((Tc>Imin)&&(Tc<Imax))
{
m=0;
f=1;
return;
} //找到启始码
if(f==1)
{
if(Tc>Inum1&&Tc<Inum3)
{
Im[m/8]=Im[m/8]>>1|0x80; m++;
}
if(Tc>Inum2&&Tc<Inum1)
{
Im[m/8]=Im[m/8]>>1; m++; //取码
}
if(m==32)
{
m=0;
f=0;
if(Im[2]==~Im[3])
{
IrOK=1;
TR0=0;
}
else IrOK=0; //取码完成后判断读码是否正确
}
//准备读下一码
}
if(IrOK==1)
{
//1键
if(Im[2]==0x0c)
{
flag=2;
}
//2键
else if(Im[2]==0x18)
{
flag=3;
}
//3键
else if(Im[2]==0x5e)
{
flag=4;
}
//4
else if(Im[2]==0x08)
{
flag=5;
}
//5
else if(Im[2]==0x1c)
{
flag=6;
}
//6
else if(Im[2]==0x5a)
{
flag=7;
}
//7键
else if(Im[2]==0x42)
{
flag=8;
}
//8
else if(Im[2]==0x52)
{
flag=9;
}
//9
else if(Im[2]==0x4a)
{
flag=10;
}
//0
else if(Im[2]==0x16)
{
flag=1;
}
//关机
else if(Im[2]==0x45)
{
flag=11;
}
IrOK=0;
}
}
void mode1()
{
if(flag==1)
{
for(i=1;i<31;i++)
{
if(flag==1)
{
P0=a_1[i-1];
P1=a_2[i-1];
P2=a_3[i-1];
P3=a_4[i-1];
delay(50);
}
}
}
}
void mode8()
{
if(flag==8)
{
for(i=0;i<2;i++)
{
if(flag==8)
{ for(j=0;j<6;j++)
{if(flag==8)
{P0=b_1[0];
P1=b_2[0];
P2=b_3[0];
P3=b_4[0];
delay(30);
P0=0xff;
P1=0xff;
P2=0xff;
P3=0xff;
delay(30);}}
for(w=0;w<6;w++)
{ if(flag==8)
{P0=b_1[1];
P1=b_2[1];
P2=b_3[1];
P3=b_4[1];
delay(30);
P0=0xff;
P1=0xff;
P2=0xff;
P3=0xff;
delay(30);}}
}
}
}
}
void mode3()
{
if(flag==3)
{
for(i=1;i<31;i++)
{
if(flag==3)
{
P0=0xe0;
P2=0xc1;
P3=0xfc;
P1=0x1f;
delay(50);
P0=0x1f;
P2=0x3e;
P3=0x0f;
P1=0xe0;
delay(50);
}
}
}
}
void main()
{
EA=1;
EX0=1;
IT0=1;
EX1=1;
IT1=1;
TMOD=0x11;
ET0=1;
flag=1;
TR0=0;
TH0=0;
TL0=0;
while(1)
{
mode1();
mode8();
mode3();
if(flag==11)
{
P0=0xff;
P2=0xff;
P3=0xff;
P1=0xff;
}
if(flag==2)
{
for(i=1;i<3;i++)
{
if(flag==2)
{
P0=b_1[i-1];
P1=b_2[i-1];
P2=b_3[i-1];
P3=b_4[i-1];
delay(50);
}
}
}
if(flag==4)
{
for(i=0;i<2;i++)
{
if(flag==4)
{
P0=0x00;
P1=0x00;
P2=0x00;
P3=0x0c;
20213205102-常喜春.zip
需积分: 0 57 浏览量
更新于2022-11-02
收藏 110KB ZIP 举报
20213205102-常喜春.zip
Chihiro303
- 粉丝: 0
- 资源: 3
最新资源
- 基于MATLAB 使用模糊逻辑算法控制给定交叉口的红绿灯系统
- android-19安卓操作系统版本8
- springboot医院病历管理系统--论文-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- springboot在线小说阅读平台_0hxfv-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- springboot智慧生活分享平台62(源码+sql+论文)-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- springboot智能菜谱推荐系统_ct3p7--论文-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 毕业生信息招聘平台-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 大学生创新创业训练项目管理系统设计与实现-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 大健康养老公寓管理系统_to14d-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 复现一篇国内中文核心,改进的DSOGI-PLL锁相环 能够对含有电压直流分量或者是含有高次谐波 都能够锁定电压基波频率50HZ
- 大学新生报到系统的设计与实现-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 大学生社团活动平台-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 儿童性教育网站-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 点餐平台网站-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 个性化电影推荐系统-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip
- 高校学生饮食推荐系统_02187-springboot毕业项目,适合计算机毕-设、实训项目、大作业学习.zip