#include sbit P3_7=P3^7; #define uchar unsigned char #define unit unsigned int uchar table[11]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff}; uchar code num[8]={0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40}; code uchar idata com1,com2,a,b,c,m,n; void delay() { uchar j ; for(j=0;j<1;j++) { TH0=0xfc; TL0=0x18; TR0=1; while(!TF0); TF0=0; } } key_scan() { uchar com; uchar i; com1=0x00; com2=0x00; delay(); P2=0x07; if(P2!=0x07) { com1=P2; P2=0x78; com2=P2; } P2=0x07; while(P2!=0x07); com=com1|com2; switch(com) { case 0x3b:i=1; break; case 0x3d:i=2; break; case 0x3e:i=3; break; case 0x5b:i=4; break; case 0x5d:i=5; break; case 0x5e:i=6; break; case 0x6b:i=7; break; case 0x6d:i=8; break; case 0x6e:i=9; break; case 0x73:i=0; break; case 0x75:P0=num[0];jia();break; case 0x76:song();i=c;break; } return(i); } jia() { b=key_scan(); P0=num[0] ; P1=table[b]; } song() { c=a+b; } void main() { TMOD=0x01; while(1) { if(P3_7==0)P0=num[0]; P2=0x07; while(P2!=0x07) { a=key_scan(); if(a<10) { P0=num[1] ; P1=table[a]; } else { while(1) { m=a/10; n=a%10; P0=num[1] ; P1=table[m]; delay(); P0=num[2] ; P1=table[n]; if(P3_7==0)break ; } P0=num[0]; } } } } 因篇幅问题不能全部显示,请点此查看更多更全内容