单片机串口通信与矩阵按钮冲突
#include<AT89X52.H>
#define uchar unsigned char 
#define uint unsigned int
void chuansonghangshu();
void jieshouhangshu();
uchar d=0;
unsigned char code a[]=
{0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
unsigned char b;
unsigned char c;
unsigned char i,j;
sbit P14=P1^4;
sbit P15=P1^5;
sbit P16=P1^6;
sbit P17=P1^7;
void delay()
{for(i=0;i<=50;i++);
}
void main(void)
{ 
TMOD=0X20;
TH1=0XE8;
TL1=0XE8;
SCON=0X50;
TR1=d;
P1=0XFF;
while(1)
{
P1=0xff;
P14=0;
b=P1;
b=b&0x0f;
if(b!=0x0f)
{
delay();
b=P1;
b=b&0x0f;
if(b!=0x0f)
{
b=P1;
b=b&0x0f;
switch(b)
{
case 0x0e:c=3;break;
case 0x0d:c=2;break;
case 0x0b:c=1;break;
case 0x07:c=0;break;
}
b=P1;
P2=a[c];
b=b&0x0f;
while(b!=0x0f)
{
b=P1;
b=b&0x0f;
}
}
}

P1=0xff;
P15=0;
b=P1;
b=b&0x0f;
if(b!=0x0f)
{
delay();
b=P1;
b=b&0x0f;
if(b!=0x0f)
{
b=P1;
b=b&0x0f;
switch(b)
{
case 0x0e:c=7;break;
case 0x0d:c=6;break;
case 0x0b:c=5;break;
case 0x07:c=4;break;
}
b=P1;
P2=a[c];
b=b&0x0f;
while(b!=0x0f)
{
b=P1;
b=b&0x0f;
}
}
}

P1=0xff;
P16=0;
b=P1;
b=b&0x0f;
if(b!=0x0f)
{
delay();
b=P1;
b=b&0x0f;
if(b!=0x0f)
{
b=P1;
b=b&0x0f;
switch(b)
{
case 0x0e:c=11;break;
case 0x0d:c=10;break;
case 0x0b:c=9;break;
case 0x07:c=8;break;
}
b=P1;
P2=a[c];
b=b&0x0f;
while(b!=0x0f)
{
b=P1;
b=b&0x0f;
}
}
}

P1=0xff;
P17=0;
b=P1;
b=b&0x0f;
if(b!=0x0f)
{
delay();
b=P1;
b=b&0x0f;
if(b!=0x0f)
{
b=P1;
b=b&0x0f;
switch(b)
{
case 0x0e:c=15;break;
case 0x0d:c=14;break;
case 0x0b:c=13;break;
case 0x07:c=12;break;
}
b=P1;
P2=a[c];
b=b&0x0f;
while(b!=0x0f)
{
b=P1;
b=b&0x0f;
}
}
}
d=P2;
SBUF=d;
while(T1==0);
T1=0;
while(RI==0)
RI=0;
d=SBUF;
P2=d;
}
} 
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐