本文包含原理图、PCB、源代码、封装库、中英文PDF等资源
您需要 登录 才可以下载或查看,没有账号?注册会员
×
#include <reg52.H>
#define uint unsigned int
#define uchar unsigned char
sbit ledlk=P1^0;
sbit smglk=P1^1;
sbit smgbitlk=P1^2;
void dealy(uchar c)
{uchar d,e;
for(d=0;d<c;d++)
for(e=0;e<120;e++);}
void display(unsigned long int a)
{ uchar code tablesmg[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf};
uchar code table[]={ 0x3f , 0x06 ,0x5b , 0x4f , 0x66 , 0x6d , 0x7d , 0x07 , 0x7f , 0x6f , 0x77 , 0x7c , 0x39 , 0x5e , 0x79 , 0x71 , 0x00};
uchar i;
uchar b[6];
b[0]=a/100000;
b[1]=(a%100000)/10000;
b[2]=(a%10000)/1000;
b[3]=(a%1000)/100;
b[4]=(a%100)/10;
b[5]=a%10;
for(i=0;i<6;i++)
{smglk=1;
P2=tablesmg[i];
smglk=0;
smgbitlk=1;
P2=table[b[i]];
smgbitlk=0;
dealy(3);} ;}
unsigned char keyscan(void)
{ uchar code anjianbiao[4][4]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
uchar tempx,tempy, x,y;
P3=0xf0;
tempy=P3&0xf0;
if(tempy!=0xf0)
{//dealy(1);
P3=0xf0;
tempy=P3;
if(tempy!=0xf0)
{ switch(tempy)
{case 0xe0:y=0;break;
case 0xd0:y=1;break;
case 0xb0:y=2;break;
case 0x70:y=3;break;} }} ;
P3=0x0f;
tempx=P3&0x0f;
if(tempx!=0x0f)
{//dealy(1);
P3=0x0f;
tempx=P3;
if(tempx!=0x0f)
{ switch(tempx)
{case 0x0e:x=0;break;
case 0x0d:x=1;break;
case 0x0b:x=2;break;
case 0x07:x=3;break;};};}
return anjianbiao[x][y]; }
void main()
{
uchar m;ledlk=0;
while(1)
{m=keyscan();
display(m);}}
键盘扫描哪里出问题了? |