求各位帮帮忙,看看我这个PROTEUS仿真电路中数码管为什么...
- UID
- 114293
|
求各位帮帮忙,看看我这个PROTEUS仿真电路中数码管为什么...
这是源程序:
#include "reg52.h"
#define uchar unsigned char
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66};
void delay()
{uchar i,j;
for(i=0;i<255;i++)
   for(j=0;j<255;j++);
}
uchar keyscan()
{uchar keyv,temp;
keyv=0;
P2=0xff;
temp=P2;
if(~(P2&temp))
{switch(temp)
{case 0xfe:
  keyv=1;break;
case 0xfd:
  keyv=2;break;
case 0xfb:
  keyv=3;break;
case 0xf7:
  keyv=4;break;
default:
  keyv=0;break;
}
}
return keyv;
}
void main ()
{
unsigned char leds;
while(1)
{leds=keyscan();
P1=table[leds];
delay();
}
}
小弟在线等......
数码管 |
|
|
|
|
|