在数码管显示12,为什么数码管一直出乱七八糟的1,2两个数字?还是仿真图的问题(在现象图片中)
单片机源程序:
- #include <reg51.h>
- #define uint unsigned int
- #define uchar unsigned char
- uchar temp,shi,ge;
- sbit dula=P2^6;
- sbit wela=P2^7;
- uchar code table[]={0xc0,0xf9,0xa4,0xb0,
- 0x99,0x92,0x82,0xf8,
- 0x80,0x98,0x88,0x83,
- 0xc6,0xa1,0x86,0x8e};
- void delay(uint z);
- void main()
- {
- temp=12;
- while(1)
- {
- shi=temp/10;
- ge=temp%10;
- dula=1;
- P0=table[shi]; //十位
- dula=0;
- wela=1;
- P0=0xfe;
- wela=0;
- delay(5);
- dula=1;
- P0=table[ge]; //个位
- dula=0;
- wela=1;
- P0=0xfd;
- wela=0;
- delay(5);
-
-
- }
-
- }
- void delay(uint z)
- {
- uint x,y;
- for(x=z;x>0;x--)
- for(y=110;y>0;y--);
- }
复制代码
|