第1,用NPN三极管(比如9012)做数码管列输入驱动滑尘
第2,用NPN或者PNP三极管(随你选)简让肢做数拦世码管行输入驱动
第3,#include
#define uint unsigned int
#define uchar unsigned char
sbit _led=P2^7;
sbit key1=P2^0;
sbit key2=P2^1;
sbit key3=P2^2;
uchar num=0,temp=0,count=0;
uchar aa;
uchar hour,min,sec;
uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
void delay(uint z);
void display(uchar a,uchar b,uchar c,uchar d,uchar e,uchar f,uchar aa);
void read_key();
void led();
void time_change();
/****************** 主函数 *******************/
void main()
{
P2=0xff;
hour=12;
min=0;
sec=0;
TMOD=0x11;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
EA=1;
ET0=1;
ET1=1;
TR0=1;
TR1=1;
aa=0xff;
while(1)
{
time_change();
display(table[hour/10],table[hour%10],table[min/10],
table[min%10],table[sec/10],table[sec%10],0xff);
}
}