林动式微笑 林动式微笑
关注数: 21 粉丝数: 52 发帖数: 1,663 关注贴吧数: 11
求大神帮忙看一下我的程序哪里错了 #include "reg52.h" sbit key1=P2^0; sbit key2=P2^1; sbit key3=P2^2; sbit key4=P2^3; sbit key5=P2^4; unsigned char code table[]={0x3f,0x0c,0x76,0x5e,0x4d,0x5b,0x7b,0x0e,0x7f,0x5f}; void delayms(unsigned int x); void display(unsigned char x,unsigned char y,unsigned char a,unsigned char b); void keyscan(); unsigned char keycts,num1,num11,num22,ge1,shi1,ge2,shi2; char num60=60; void main() { TMOD=0x01; TH0=(65536-45872)/256; TL0=(65536-45872)%256; EA=1; ET0=1; TR0=1; while(1) { if(TR0==0) { if(keycts==1) P0=0xbe; else if(keycts==2) P0=0xee; else if(keycts==3) P0=0xbb; else if(keycts==4) P0=0x3e; else P0=0xb6; } else { if(num60-40>0) { num11=num60-30; num22=num60-35; P0=0xee; } else if(num60-35>0) { num11=num60-30; num22=num60-35; if(num1<=10) P0=0xde; else P0=0xfe; } else if(num60-30>0) { num11=num60-30; num22=num60-30; P0=0x3e; } else if(num60-10>0) } { num11=num60-5; num22=num60; P0=0xbb; } else if(num60-5>0) { num11=num60-5; num22=num60; if (num1<=10) P0=0xbd; else P0=0xbf; } else { num11=num60; num22=num60; P0=0xb6; } shi1=num11/10; ge1=num11%10; shi2=num22/10; ge2=num22%10; dispaly(shi1,ge1,shi2,ge2); keyscan(); }} void display(unsigned char x,unsigned char y,unsigned char a,unsigned char b) { P1=table[x];P3=0xfe;delayms(1); P1=table[y];P3=0xfd;delayms(1); P1=table[a];P3=0xfb;delayms(1); P1=table[b];P3=0xf7;delayms(1); } void delayms(unsigned int x) { unsigned int i,j; for(i=x;i>0;i--) for (j=110;j>0;j--); } void T0_time()interrupt 1 { TH0=(65536-45872)/256; TL0=(65536-45872)%256; num1 ++; if(num1==20) { num1=0; num60--; if(num60==0) num60=60; } } void keyscan() { if (key1==0) { delayms(10); if(key1==0) { while(!key1); TR0=~TR0; keycts=1; } } if (key2==0) { delayms(10); if(key2==0) { while(!key2); TR0=~TR0; keycts=2; } } if (key3==0) { delayms(10); if(key3==0) { while(!key3); TR0=~TR0; keycts=3; } } if (key4==0) { delayms(10); if(key4==0) { while(!key4); TR0=~TR0; keycts=4; } } if (key5==0) { delayms(10); if(key5==0) { while(!key5); TR0=~TR0; keycts=5; } } }
1 下一页