专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
帮忙看一下设计哪里有问题。(无线收发系统,通过lcd显示键盘的输入)
2019-03-24 17:42
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
51单片机
8410
4
1160
下面是程序
此帖出自
小平头技术问答
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
4条回答
凇聆
2019-03-24 22:02
发射---
#include <AT89X51.h>
static bit OP;
static unsigned int count;
static unsigned int endcount;
static unsigned char Flag;
char iraddr1;
char iraddr2;
void SendIRdata(char p_irdata);
void delay();
char getkey()
{
P1=0xfe;P3_6=P3_7=1;P3_3=1;
if(!P1_4)return 1;
if(!P1_5)return 2;
if(!P1_6)return 3;
if(!P1_7)return 4;
if(!P3_6)return 5;
if(!P3_7)return 6;
P1=0xfd;
if(!P1_4)return 11;
if(!P1_5)return 12;
if(!P1_6)return 13;
if(!P1_7)return 14;
if(!P3_6)return 15;
if(!P3_7)return 16;
P1=0xfb;
if(!P1_4)return 21;
if(!P1_5)return 22;
if(!P1_6)return 23;
if(!P1_7)return 24;
if(!P3_6)return 25;
if(!P3_7)return 26;
P1=0xf7;
if(!P1_4)return 31;
if(!P1_5)return 32;
if(!P1_6)return 33;
if(!P1_7)return 34;
if(!P3_6)return 35;
if(!P3_7)return 36;
P1=0xfF;P3_3=0;
if(!P1_4)return 41;
if(!P1_5)return 42;
if(!P1_6)return 43;
if(!P1_7)return 44;
if(!P3_6)return 45;
if(!P3_7)return 46;
return 0;
}
void main(void)
{
char key;
count = 0;
Flag = 0;
OP = 0;
P3_4 = 1;
EA = 1;
TMOD = 0x11;
ET0 = 1;
P1=0xff;
TH0 = 0xFF;
TL0 = 0xE6;
TR0 = 1;
iraddr1=0xff;
iraddr2=0xff;
do{
key=getkey();
if(key==1)SendIRdata(0x12);
if(key==11)SendIRdata(0x0b);
if(key==25||key==35)SendIRdata(0x1a);
if(key==15)SendIRdata(0x1e);
if(key==6)SendIRdata(0x0e);
if(key==16)SendIRdata(0x1d);
if(key==26)SendIRdata(0x1f);
if(key==36)SendIRdata(0x1b);
if(key==32)SendIRdata(0x00);
if(key==22)SendIRdata(0x01);
if(key==23)SendIRdata(0x02);
if(key==24)SendIRdata(0x03);
if(key==12)SendIRdata(0x04);
if(key==13)SendIRdata(0x05);
if(key==14)SendIRdata(0x06);
if(key==2)SendIRdata(0x07);
if(key==3)SendIRdata(0x08);
if(key==4)SendIRdata(0x09);
if(key==21)SendIRdata(0x2A);
if(key==5)SendIRdata(0x2B);
if(key==33)SendIRdata(0x2C);
if(key==34)SendIRdata(0x2D);
if(key==31)SendIRdata(0x2E);
if(key==41)SendIRdata(0x2F);
if(key==42)SendIRdata(0x30);
if(key==43)SendIRdata(0x31);
if(key==44)SendIRdata(0x32);
if(key==45)SendIRdata(0x33);
if(key==46)SendIRdata(0x34);
}while(1);
}
void timeint(void) interrupt 1
{
TH0=0xFF;
TL0=0xE6;
count++;
}
void SendIRdata(char P_irdata)
{
int i;
char irdata=P_irdata;
endcount=223;
Flag=1;
count=0;
P3_4=0;
do{}while(count<endcount);
endcount=117;
Flag=0;
count=0;
P3_4=1;
do{}while(count<endcount);
irdata=iraddr1;
for(i=0;i<8;i++)
{
endcount=10;
Flag=1;
count=0;
P3_4=0;
do{}while(count<endcount);
if(irdata-(irdata/2)*2)
{
endcount=15;
}
else
{
endcount=41;
}
Flag=0;
count=0;
P3_4=1;
do{}while(count<endcount);
irdata=irdata>>1;
}
irdata=iraddr2;
for(i=0;i<8;i++)
{
endcount=10;
Flag=1;
count=0;
P3_4=0;
do{}while(count<endcount);
if(irdata-(irdata/2)*2)
{
endcount=15;
}
else
{
endcount=41;
}
Flag=0;
count=0;
P3_4=1;
do{}while(count<endcount);
irdata=irdata>>1;
}
irdata=~P_irdata;
for(i=0;i<8;i++)
{
endcount=10;
Flag=1;
count=0;
P3_4=0;
do{}while(count<endcount);
if(irdata-(irdata/2)*2)
{
endcount=15;
}
else
{
endcount=41;
}
Flag=0;
count=0;
P3_4=1;
do{}while(count<endcount);
irdata=irdata>>1;
}
irdata=P_irdata;
for(i=0;i<8;i++)
{
endcount=10;
Flag=1;
count=0;
P3_4=0;
do{}while(count<endcount);
if(irdata-(irdata/2)*2)
{
endcount=15;
}
else
{
endcount=41;
}
Flag=0;
count=0;
P3_4=1;
do{}while(count<endcount);
irdata=irdata>>1;
}
endcount=10;
Flag=1;
count=0;
P3_4=0;
do{}while(count<endcount);
P3_4=1;
Flag=0;
}
void delay()
{
int i,j;
for(i=0;i<400;i++)
{
for(j=0;j<100;j++)
{
}
}
}
加载中...
查看其它4个回答
一周热门
更多
>
相关问题
相关文章
基于51单片机的计算器设计
0个评论
51单片机300个proteus仿真实例下载
0个评论
51单片机 蜂鸣器
0个评论
51单片机驱动RC522模块
0个评论
基于51单片机的指纹密码锁
0个评论
AT89C51单片机制作简易密码锁
0个评论
51单片机汇编语言计数器
0个评论
51单片机精确延时设计
0个评论
×
关闭
采纳回答
向帮助了您的知道网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
×
付费偷看金额在0.1-10元之间
确定
×
关闭
您已邀请
0
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
#include <AT89X51.h>
static bit OP;
static unsigned int count;
static unsigned int endcount;
static unsigned char Flag;
char iraddr1;
char iraddr2;
void SendIRdata(char p_irdata);
void delay();
char getkey()
{
P1=0xfe;P3_6=P3_7=1;P3_3=1;
if(!P1_4)return 1;
if(!P1_5)return 2;
if(!P1_6)return 3;
if(!P1_7)return 4;
if(!P3_6)return 5;
if(!P3_7)return 6;
P1=0xfd;
if(!P1_4)return 11;
if(!P1_5)return 12;
if(!P1_6)return 13;
if(!P1_7)return 14;
if(!P3_6)return 15;
if(!P3_7)return 16;
P1=0xfb;
if(!P1_4)return 21;
if(!P1_5)return 22;
if(!P1_6)return 23;
if(!P1_7)return 24;
if(!P3_6)return 25;
if(!P3_7)return 26;
P1=0xf7;
if(!P1_4)return 31;
if(!P1_5)return 32;
if(!P1_6)return 33;
if(!P1_7)return 34;
if(!P3_6)return 35;
if(!P3_7)return 36;
P1=0xfF;P3_3=0;
if(!P1_4)return 41;
if(!P1_5)return 42;
if(!P1_6)return 43;
if(!P1_7)return 44;
if(!P3_6)return 45;
if(!P3_7)return 46;
return 0;
}
void main(void)
{
char key;
count = 0;
Flag = 0;
OP = 0;
P3_4 = 1;
EA = 1;
TMOD = 0x11;
ET0 = 1;
P1=0xff;
TH0 = 0xFF;
TL0 = 0xE6;
TR0 = 1;
iraddr1=0xff;
iraddr2=0xff;
do{
key=getkey();
if(key==1)SendIRdata(0x12);
if(key==11)SendIRdata(0x0b);
if(key==25||key==35)SendIRdata(0x1a);
if(key==15)SendIRdata(0x1e);
if(key==6)SendIRdata(0x0e);
if(key==16)SendIRdata(0x1d);
if(key==26)SendIRdata(0x1f);
if(key==36)SendIRdata(0x1b);
if(key==32)SendIRdata(0x00);
if(key==22)SendIRdata(0x01);
if(key==23)SendIRdata(0x02);
if(key==24)SendIRdata(0x03);
if(key==12)SendIRdata(0x04);
if(key==13)SendIRdata(0x05);
if(key==14)SendIRdata(0x06);
if(key==2)SendIRdata(0x07);
if(key==3)SendIRdata(0x08);
if(key==4)SendIRdata(0x09);
if(key==21)SendIRdata(0x2A);
if(key==5)SendIRdata(0x2B);
if(key==33)SendIRdata(0x2C);
if(key==34)SendIRdata(0x2D);
if(key==31)SendIRdata(0x2E);
if(key==41)SendIRdata(0x2F);
if(key==42)SendIRdata(0x30);
if(key==43)SendIRdata(0x31);
if(key==44)SendIRdata(0x32);
if(key==45)SendIRdata(0x33);
if(key==46)SendIRdata(0x34);
}while(1);
}
void timeint(void) interrupt 1
{
TH0=0xFF;
TL0=0xE6;
count++;
}
void SendIRdata(char P_irdata)
{
int i;
char irdata=P_irdata;
endcount=223;
Flag=1;
count=0;
P3_4=0;
do{}while(count<endcount);
endcount=117;
Flag=0;
count=0;
P3_4=1;
do{}while(count<endcount);
irdata=iraddr1;
for(i=0;i<8;i++)
{
endcount=10;
Flag=1;
count=0;
P3_4=0;
do{}while(count<endcount);
if(irdata-(irdata/2)*2)
{
endcount=15;
}
else
{
endcount=41;
}
Flag=0;
count=0;
P3_4=1;
do{}while(count<endcount);
irdata=irdata>>1;
}
irdata=iraddr2;
for(i=0;i<8;i++)
{
endcount=10;
Flag=1;
count=0;
P3_4=0;
do{}while(count<endcount);
if(irdata-(irdata/2)*2)
{
endcount=15;
}
else
{
endcount=41;
}
Flag=0;
count=0;
P3_4=1;
do{}while(count<endcount);
irdata=irdata>>1;
}
irdata=~P_irdata;
for(i=0;i<8;i++)
{
endcount=10;
Flag=1;
count=0;
P3_4=0;
do{}while(count<endcount);
if(irdata-(irdata/2)*2)
{
endcount=15;
}
else
{
endcount=41;
}
Flag=0;
count=0;
P3_4=1;
do{}while(count<endcount);
irdata=irdata>>1;
}
irdata=P_irdata;
for(i=0;i<8;i++)
{
endcount=10;
Flag=1;
count=0;
P3_4=0;
do{}while(count<endcount);
if(irdata-(irdata/2)*2)
{
endcount=15;
}
else
{
endcount=41;
}
Flag=0;
count=0;
P3_4=1;
do{}while(count<endcount);
irdata=irdata>>1;
}
endcount=10;
Flag=1;
count=0;
P3_4=0;
do{}while(count<endcount);
P3_4=1;
Flag=0;
}
void delay()
{
int i,j;
for(i=0;i<400;i++)
{
for(j=0;j<100;j++)
{
}
}
}
一周热门 更多>