At first I wanted to use interrupts, but in the end I ended up using code.
#include
#define uchar unsigned char
#define uint unsigned int
uchar code tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};// Digital table
uchar num1; //Display tens digit
uchar num0; //Display units digit
//---------------------------------
void delay(uint k) //Delay
{
while(k--);
}
//-----------------------------
void main()
{
uchar j;
TMOD=0x20;
TH1=0xfd;
TL1=0xfd;
TR1=1;
SCON=0x50;
while(1)
{
while(RI==1) //Input the first number
{
j=SBUF;
num1=j-'0';
RI=0;
while(RI==0); // Enter the second number
j=SBUF;
num0=j-'0';
RI=0;
}
P0=tab[num1];
P2=0xfd;
delay(100);
P0=tab[num0];
P2=0xfe;
delay(100);
}
}
Reference address:Use the serial port to input integer simple code
Previous article:"Screen-style" sound and light electronic keyboard program
Next article:RS-485 multi-machine communication program (host side)
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
MoreDaily News
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
Guess you like
- Can you tell me what the Cf2 capacitor does in the circuit? Thanks!
- What is the purpose of connecting two PMOS in series?
- Top 10 hot technologies in 2019: 5G ranks first, and "brain-computer interaction" achieves breakthrough
- DSP Demo Programming Example Sharing
- Fudan Micro FM33LC046N Evaluation + External Interrupt
- A brief discussion on the technological innovation and market prospects of Wi-Fi 6E
- Why embedded engineers have misunderstandings about 8-bit MCUs
- Disassemble BYD's smart car key to see what solution it uses
- ST official statement: STM8 and STM32 production capacity description
- Practical Tips