Home > other >  Why can't the digital tube display, please input the number
Why can't the digital tube display, please input the number

Time:09-26

#include
Unsigned char flag, bai, shi, ge, shiwan, wan, qian;
# define uint unsigned int
# define uchar unsigned char
Uint a;
sbit wela=P2^7;
sbit dula=P2^6;
Unsigned char code table []={x5b x3f 0, 0 x06, 0, 0 x4f, 0 x66, 0 x6d,
X07 0 x7d, 0, 0 x7f, 0 x6f, 0 x77, 0 x7c,
X5e 0 x39, 0, 0 x79, 0 x71};
Void delay (uint z)
{
Uint x, y;
For (x=z; X> 0; X -)
For (y=110; Y> 0; y--);
}
Void the display (uchar bai, uchar shi, uchar ge, uchar shiwan, uchar wan, uchar qian)
{
dula=1;
P0=table [shiwan];
dula=0;
P0=0 XFF;
wela=1;
P0=0xfe;
wela=0;
delay(1);

dula=1;
P0=table (wan);
dula=0;
P0=0 XFF;
wela=1;
P0=0xfd;
wela=0;
delay(1);

dula=1;
[qian P0=table];
dula=0;
P0=0 XFF;
wela=1;
P0=0xfb;
wela=0;
delay(1);

dula=1;
P0=table (bai);
dula=0;
P0=0 XFF;
wela=1;
P0=0xf7;
wela=0;
delay(1);

dula=1;
P0=table (shi);
dula=0;
P0=0 XFF;
wela=1;
P0=0xef;
wela=0;
delay(1);

dula=1;
P0=table (ge),
dula=0;
P0=0 XFF;
wela=1;
P0=0xdf;
wela=0;
delay(1);
}
Void main ()
{
Flag=1;
SCON=0 x50;//set the serial port works, 0101, 0000
PCON=0 x00;
TMOD=0 x20;
TH1=0 XFD;
TL1=0 XFD;
TR1=1;
EA=1;
ES=1;
While (1)
{
If (flag==1)
{
ES=0;
Flag=0;
SBUF=a;
while(! TI);
TI=0;
ES=1;
}
The display (bai shi, ge, shiwan, wan, qian);
}
}
Void serial interrupt 4 ()
{
RI=0;
A=SBUF;
Shiwan=a/100000;
Wan a %=100000/10000;
Qian a %=10000/1000;
Bai a %=1000/100;
Shi=a % 100/10;
Ge=a % 10;
}

CodePudding user response:

The
refer to the original poster an_ch response:
# include
Unsigned char flag, bai, shi, ge, shiwan, wan, qian;
# define uint unsigned int
# define uchar unsigned char
Uint a;
sbit wela=P2^7;
sbit dula=P2^6;
Unsigned char code table []={x5b x3f 0, 0 x06, 0, 0 x4f, 0 x66, 0 x6d,
X07 0 x7d, 0, 0 x7f, 0 x6f, 0 x77, 0 x7c,
X5e 0 x39, 0, 0 x79, 0 x71};
Void delay (uint z)
{
Uint x, y;
For (x=z; X> 0; X -)
For (y=110; Y> 0; y--);
}
Void the display (uchar bai, uchar shi, uchar ge, uchar shiwan, uchar wan, uchar qian)
{
dula=1;
P0=table [shiwan];
dula=0;
P0=0 XFF;
wela=1;
P0=0xfe;
wela=0;
delay(1);

dula=1;
P0=table (wan);
dula=0;
P0=0 XFF;
wela=1;
P0=0xfd;
wela=0;
delay(1);

dula=1;
[qian P0=table];
dula=0;
P0=0 XFF;
wela=1;
P0=0xfb;
wela=0;
delay(1);

dula=1;
P0=table (bai);
dula=0;
P0=0 XFF;
wela=1;
P0=0xf7;
wela=0;
delay(1);

dula=1;
P0=table (shi);
dula=0;
P0=0 XFF;
wela=1;
P0=0xef;
wela=0;
delay(1);

dula=1;
P0=table (ge),
dula=0;
P0=0 XFF;
wela=1;
P0=0xdf;
wela=0;
delay(1);
}
Void main ()
{
Flag=1;
SCON=0 x50;//set the serial port works, 0101, 0000
PCON=0 x00;
TMOD=0 x20;
TH1=0 XFD;
TL1=0 XFD;
TR1=1;
EA=1;
ES=1;
While (1)
{
If (flag==1)
{
ES=0;
Flag=0;
SBUF=a;
while(! TI);
TI=0;
ES=1;
}
The display (bai shi, ge, shiwan, wan, qian);
}
}
Void serial interrupt 4 ()
{
RI=0;
A=SBUF;
Shiwan=a/100000;
Wan a %=100000/10000;
Qian a %=10000/1000;
Bai a %=1000/100;
Shi=a % 100/10;
Ge=a % 10;
}

See the schematic diagram, is likely to use the decoder control
  • Related