标签:span rup reg -- ++ err tab unsigned har
1 #include<reg51.h> 2 3 4 #define unint unsigned int 5 #define unchar unsigned char 6 7 sbit k=P3^2; 8 sbit L=P1^0; 9 10 unint a=1,b=1,c=1,d=1,s=0; 11 unchar code table[]={0xc0,0xf9,0xa4,0xb0, 12 0x99,0x92,0x82,0xf8, 13 0x80,0x90}; 14 15 16 void delay(unint x) 17 { 18 unint i,j; 19 for(i=121;i>0;i--) 20 for(j=0;j<=x;j++); 21 } 22 23 void main() 24 { 25 L=0; 26 P2=0x0f; 27 P0=table[0]; 28 IT0=0; 29 EA=1; 30 EX0=1; 31 while(1); 32 33 } 34 35 void cut_num(void) 36 { 37 if(s==10000) 38 s=0; 39 d=s%10; 40 c=(s/10)%10; 41 b=(s/100)%10; 42 a=(s/1000)%10; 43 } 44 void print_num() 45 { 46 delay(1); 47 P2=0x08; 48 P0=table[d]; 49 if((a!=0)||(b!=0)||(a==0&&b==0&&c!=0)) 50 { 51 delay(1); 52 P2=0x04; 53 P0=table[c]; 54 } 55 if(a!=0||(a==0&&b!=0)) 56 { 57 delay(1); 58 P2=0x02; 59 P0=table[b]; 60 } 61 if(a!=0) 62 { 63 delay(1); 64 P2=0x01; 65 P0=table[a]; 66 } 67 } 68 void int0()interrupt 0 69 { 70 71 s++; 72 cut_num(); 73 delay(300); 74 while(k==0) 75 print_num(); 76 while(k!=0) 77 print_num(); 78 79 80 }
标签:span rup reg -- ++ err tab unsigned har
原文地址:http://www.cnblogs.com/wangyishan/p/7688165.html