本程序是八个数码管显12345678,但我编译,老说我变量未定义~~
qw bw sw w q b s g分别表示千万,百万,十万,万,千,百,十,个
我光显示123就很成功,但现在只是将数字加大,而且我没用整形,用了unsigned long了,还不行吗?请高手指点!
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
#define ulong unsigned long
uchar code duan[]=
{
0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f
};
uchar code wei[]=
{
0x7f,0xbf,0xdf,0xef,
0xf7,0xfb,0xfd,0xfe
};
void delay(uchar z)
{
uchar x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void display(uchar qw,uchar bw,uchar sw,uchar w,uchar q,uchar b,uchar s,uchar g)
{
P0=duan[qw];
P2=wei[0];
delay(5);
P0=duan[bw];
P2=wei[1];
delay(5);
P0=duan[sw];
P2=wei[2];
delay(5);
P0=duan[w];
P2=wei[3];
delay(5);
P0=duan[q];
P2=wei[4];
delay(5);
P0=duan[b];
P2=wei[5];
delay(5);
P0=duan[s];
P2=wei[6];
delay(5);
P0=duan[g];
P2=wei[7];
delay(5);
}
uint ge,shi,bai;
ulong shu;
void main()
{
shu=12345678;
while(1)
{
qw=shu/10000000;
bw=shu%10000000/1000000;
sw=shu%10000000%1000000/100000;
w=shu%10000000%1000000%100000/10000;
q=shu%10000000%1000000%100000%10000/1000;
b=shu%10000000%1000000%100000%10000%1000/100;
s=shu%10000000%1000000%100000%10000%1000%100/10;
g=shu%10000000%1000000%100000%10000%1000%100%10;
display (qw,bw,sw,w,q,b,s,g);
}
}