本人新手基础知识不好 大家多指教 莫嘲笑。给看看程序哪里不对
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
uint xms;
uchar aa;
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
uchar code jp[]={0xee,0xde,0xbe,0x7e,
0xed,0xdd,0xbd,0x7d,
0xdb,0xdb,0xbb,0x7b,
0xe7,0xd7,0xb7,0x77,};
void delay(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=130;j>0;j--);
}
void keyscan()
{
uchar xy,x,y,j,temp,aa;
P3=0xf0;
temp=P3;
temp=temp&0xf0;
if(temp!=0xf0)
{
delay(10);
temp=P3;
temp=temp&0xf0;
if(temp!=0xf0)
x=temp|0xf0;
}
P3=0x0f;
temp=P3;
temp=temp&0x0f;
if(temp!=0x0f)
{
delay(10);
temp=P3;
temp=temp&0x0f;
if(temp!=0x0f)
{
y=temp|0xf0;
}
}
xy=x|y;
for(j=0;j<16;j++)
{
if(xy==jp[j])
aa=j;
}
while(temp!=0xf0)
{
temp=P3;
temp=temp&0xf0;
}
}
void main()
{
while(1)
{
keyscan();
P0=~table[aa];
}
}
|