Home > other >  Communication serial port with digital tube display
Communication serial port with digital tube display

Time:09-25

#include
Unsigned char flag, bai, shi ge;
# 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)
{
dula=1;
P0=table (bai);
dula=0;
P0=0 XFF;
wela=1;
P0=0 xfe;
wela=0;
delay(1);

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

dula=1;
P0=table (ge),
dula=0;
P0=0 XFF;
wela=1;
P0=0 XFB;
wela=0;
delay(1);
}
Void main ()
{
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;
Bai=a/100;
Shi=a % 100/10;
Ge=a % 10;
ES=1;
}
The display (bai shi, ge);
}
}
Void ser () interrupt 4
{
While (RI)

RI=0;
A=SBUF;

Flag=1;

}
Excuse me why computer input number less than 10, the digital tube can display the corresponding normal number, and the number is greater than or equal to I0, digital tube display can't correspond to the normal number

CodePudding user response:

When you enter 10 shows what

CodePudding user response:

When I type 10 16, 20 show 32 input

CodePudding user response:

Priority when uncertain advice (a % 100)/10 brackets

CodePudding user response:

reference zgl7903 reply: 3/f
priority when uncertain advice (a % 100)/10 brackets

Excuse me, is there any way the computer sent to MCU a number, the digital tube will display a number

CodePudding user response:

refer to the second floor weixin_45882552 response:
16, when I input 10 input 20 show 32

The building Lord PC sends is the hexadecimal number,

CodePudding user response:

reference 5 floor yishumei reply:
Quote: refer to the second floor weixin_45882552 response:

Input at 16, I enter 20 show 32

Host PC sends a hexadecimal number,

Well, what method to send text phenomenon

CodePudding user response:

refer to 6th floor weixin_45882552 response:
Quote: refer to the 5 floor yishumei response:
Quote: refer to the second floor weixin_45882552 response:

Input at 16, I enter 20 show 32

Host PC sends a hexadecimal number,

Uh, excuse me, is there any way to send phenomenon

Send text need to modify the program, the original poster on the hexadecimal conversion, decimal convert hexadecimal number (for example, 11 - & gt; 0 x0b, 17 - & gt; 0 x11), then the send button,

CodePudding user response:

Excuse me, want to translate the zha write,

CodePudding user response:

refer to 7th floor yishumei response:
Quote: refer to the sixth floor weixin_45882552 response:

Quote: refer to the 5 floor yishumei response:
Quote: refer to the second floor weixin_45882552 response:

Input at 16, I enter 20 show 32

Host PC sends a hexadecimal number,

Uh, excuse me, is there any way to send phenomenon

Send text need to modify the program, the original poster on the hexadecimal conversion, decimal convert hexadecimal number (for example, 11 - & gt; 0 x0b, 17 - & gt; 0 x11), then the send button,

Write, please translate the zha,

CodePudding user response:

Sorry, I didn't say clear, I mean the building Lord you don't need to modify the program, PC send when converting a hexadecimal went, how hexadecimal conversion is the basic skills, use the Internet to learn to study, do not understand,

CodePudding user response:

references to the tenth floor yishumei response:
I'm sorry, I didn't say clear, I mean the building Lord you don't need to modify the program, PC sends when converting a hexadecimal went, how hexadecimal conversion is the basic skills, use the Internet to learn to study, do not understand,

Can't change, our task must be to use text sends the corresponding digital, digital tube will display the corresponding Numbers,

CodePudding user response:

What method,? To the tenth floor, thank you

CodePudding user response:

refer to 12 floor weixin_45882552 reply:
what method, 10th floor, thank you

PC software cut a figure to see,

CodePudding user response:

Consistent and upper machine base can
According to the above described PC should be according to the BCD said
Bai=0;
Shi=(a> 4);
Ge=(a& 0 x0f);

CodePudding user response:

On the 14th floor zgl7903
reference response:
and upper machine base consistent can
According to the above described PC should be according to the BCD said
Bai=0;
Shi=(a> 4);
Ge=(a& 0 x0f);

Single digit accurately, ten digits is not accurate, 12 32 hair 54 show 34
  • Related