本帖最后由 datouyuan 于 2015-8-31 09:34 编辑
void Display(unsigned long int x)
你的显示只有4位,应改成void Display(unsigned int x)
- //从高位开始显示简单些
- void Display(unsigned int x)
- {
- unsigned char a[4];
- bit bBit=0;
- a[0]=x%10; a[1]=x/10%10;
- a[2]=x/100%10; a[3]=x/1000%10;
- if(bBit || a[3])
- {
- bBit=1;
- P1=0xfe;
- P0=0xff;
- P0=Tab[a[3]];
- delay1ms(1);
- }
- if(bBit || a[2])
- {
- bBit=1;
- P1=0xfd;
- P0=0xff;
- P0=Tab[a[2]];
- delay1ms(1);
- }
- if(bBit || a[1])
- {
- bBit=1;
- P1=0xfb;
- P0=0xff;
- P0=Tab[a[1]];
- delay1ms(1);
- }
- P1=0xf7;
- P0=0xff;
- P0=Tab[a[0]];
- delay1ms(1);
- }
|