Home > other >  Great god answer of why I digital tube, not bright
Great god answer of why I digital tube, not bright

Time:11-26



# include

# define GPIO_DIG P2
# define GPIO_PLACE P0
P1 sbit k=^ 0;

Unsigned char code DIG_PLACE [8]={XFD 0 xfe, 0, 0 XFB, 0 xf7, 0 xef, 0 XDF, 0 XBF, 0 x7f};

Unsigned char code DIG_CODE [17]={x5b x3f 0, 0 x06, 0, 0, x4f x66 0, 0 x6d, 0 x7d, 0 x07, 0 x7f, 0 x6f, 0 x77, 0 x7c, 0 x39, 0 x5e, 0 x79, 0 x71};

Unsigned char DisplayData [8].

Void Displaykey ();
Void Runkey ();
Void first ();
Void step1 ();
Void step2 ();
Void step3 ();
Void step4 ();

Signed char delay;
Signed char I;
Unsigned char j;
Signed char i1.
Unsigned int step=1;


Void main (void)
{
Unsigned char a;
For (a=0; a<8; +)

{
DisplayData [a]=DIG_CODE [a];
}
The first ();
While (1)
{
Displaykey ();
Runkey ();
}
}
Void first ()
{
TMOD=0x01;
TH0=(65536-20000)/256;
TL0=(65536-20000) % 256;
IE=0 x82;
}
Void Displaykey ()
{
If (k==0)
TR0=1;
}
Void time0 () interrupt using 1
{
Unsigned char a;
TH0=(65536-20000)/256;
TL0=(65536-20000) % 256;
If (k==0)
{
While (1)
{
If (k==1) break;
}
Step=step + 1;
If (step==5)
Step=1;
The switch (step)
{
Case 1: I=0; break;
Case 2: I=7. break;
Case 3: I=0; I1=7. break;
Case 4: I=3; I1=4; break;
}
}
a++;
While (a==20)
{
a=0;
Delay=1;
}
TR0=0;
}
Void Runkey ()
{
The switch (step)
{
Case 1: step1 (); break;
Case 2: step2 (); break;
Case 3: step 3 (); break;
Case 4: step4 (); break;
}
}

Void step1 ()
{
GPIO_PLACE=DIG_PLACE [I];
GPIO_DIG=DisplayData [I];
J=10;
While (j);
GPIO_DIG=0 x00;
TR0=1;
While (delay==1)
{
Delay=0;
i=i+1;
While (I==8)
i=0;
}
}
Void step2 ()
{
GPIO_PLACE=DIG_PLACE [I];
GPIO_DIG=DisplayData [I];
J=10;
While (j);
GPIO_DIG=0 x00;
TR0=1;
While (delay==1)
{
Delay=0;
I=I - 1;
While (I==1)
I=7.
}
}
Void step3 ()
{
GPIO_PLACE=DIG_PLACE [I];
GPIO_DIG=DisplayData [I];
J=10;
While (j);
GPIO_DIG=0 x00;
GPIO_PLACE=DIG_PLACE (i1);
GPIO_DIG=DisplayData (i1);
J=10;
While (j);
GPIO_DIG=0 x00;
TR0=1;
While (delay==1)
{
Delay=0;
i=i+1;
I1=i1-1;
While (i1==3)
{
i=0;
I1=7.
}
}
}
Void step4 ()
{
GPIO_PLACE=DIG_PLACE [I];
GPIO_DIG=DisplayData [I];
J=10;
While (j);
GPIO_DIG=0 x00;
GPIO_PLACE=DIG_PLACE (i1);
GPIO_DIG=DisplayData (i1);
J=10;
While (j);
GPIO_DIG=0 x00;
TR0=1;
While (delay==1)
{
Delay=0;
I=I - 1;
I1=i1 + 1;
While (i1==8)
{
I=3;
I1=4;
}
}
}

CodePudding user response:

Connection points on the simulation diagram is wrong, letter case is different, after defined the node with chosen don't have to write,
Pull-up resistors only P0 need other all need not,

CodePudding user response:

This aspect of the problem in electronic BBS asked,

CodePudding user response:

The
refer to the original poster zhizhuQi response:


# include

# define GPIO_DIG P2
# define GPIO_PLACE P0
P1 sbit k=^ 0;

Unsigned char code DIG_PLACE [8]={XFD 0 xfe, 0, 0 XFB, 0 xf7, 0 xef, 0 XDF, 0 XBF, 0 x7f};

Unsigned char code DIG_CODE [17]={x5b x3f 0, 0 x06, 0, 0, x4f x66 0, 0 x6d, 0 x7d, 0 x07, 0 x7f, 0 x6f, 0 x77, 0 x7c, 0 x39, 0 x5e, 0 x79, 0 x71};

Unsigned char DisplayData [8].

Void Displaykey ();
Void Runkey ();
Void first ();
Void step1 ();
Void step2 ();
Void step3 ();
Void step4 ();

Signed char delay;
Signed char I;
Unsigned char j;
Signed char i1.
Unsigned int step=1;


Void main (void)
{
Unsigned char a;
For (a=0; a<8; +)

{
DisplayData [a]=DIG_CODE [a];
}
The first ();
While (1)
{
Displaykey ();
Runkey ();
}
}
Void first ()
{
TMOD=0x01;
TH0=(65536-20000)/256;
TL0=(65536-20000) % 256;
IE=0 x82;
}
Void Displaykey ()
{
If (k==0)
TR0=1;
}
Void time0 () interrupt using 1
{
Unsigned char a;
TH0=(65536-20000)/256;
TL0=(65536-20000) % 256;
If (k==0)
{
While (1)
{
If (k==1) break;
}
Step=step + 1;
If (step==5)
Step=1;
The switch (step)
{
Case 1: I=0; break;
Case 2: I=7. break;
Case 3: I=0; I1=7. break;
Case 4: I=3; I1=4; break;
}
}
a++;
While (a==20)
{
a=0;
Delay=1;
}
TR0=0;
}
Void Runkey ()
{
The switch (step)
{
Case 1: step1 (); break;
Case 2: step2 (); nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related