你對照一下就知道哪里不對
#include <reg51.h>
#define uint unsigned int
#define uchar unsigned char
sbit dula=P2^6;
sbit wela=P2^7;
//順序共陰極數碼管段碼表,段碼a-h順序接PX0-PX7
uchar code table[]={//共陰數碼管段碼"0~f-."
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,0x40,0x80};
void Delay_ms(uint t)
{
uint i,j;
for(i=t;i>0;i--)
for(j=110;j>0;j--);
}
void main()
{
uchar i;
while(1)
{
P0=0x00;dula=1;dula=0;
P0=~(0x01<<i);wela=1;wela=0;
P0=table[i+1];dula=1;dula=0;
i=++i%6;
Delay_ms(1);
}
}
|