-
#define uint unsigned int
#define uchar unsigned char
sbit k1=P2^0;
sbit k2=P2^1;
uint code table[]={0X00,0X80,0X10,0X90,0X20,0XA0,0X30,0XB0,0X40,0XC0 };
void delay(uint z)
{
uint a,b;
for(a=z;a>0;a--)
{
for(b=z;b>0;b--);
}
}
void main()
{
int c=99,t,shi,ge;
for(t=99;t>0;t--)
{
shi=c/10;
ge=c;
k1=0,k2=1;
P1=table[shi ];
delay(300);
P1=0XFF;
k2=0,k1=1;
P1=table[ge];
delay(200);
P1=0XFF;
k1=0,k2=0;
c--;
if(c ==0)
c=99;
}
}
- answer:
-
It must be different at the same time, because you showed it as ten and then one.
In fact, the so-called simultaneous display means that if the cycle scanning time interval is short, it will naturally appear to be simultaneous.
What you have to do is to display the tens digit and then the ones digit while displaying the delay , instead of displaying one and then the other.
The best way is to put it in the interrupt to ensure the display effect.
bit flag;
int shi ,ge;
These three are external variables
and it should be OK to call this function during the delay process. void shown()
{
if (flag==0)
{
P1=table[shi];k2=1,k1=0;
}
else
{
P1=table[ge];k2=0,k1=1;
}
flag=~flag;
}
Previous article:C51 MCU data type range
Next article:C51 MCU delay program source code
- Popular Resources
- Popular amplifiers
- Learn ARM development(15)
- 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)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Today at 10 am, Beineng International will broadcast [New Glass Breakage Detection Solution] (Must-see for security and smart home)
- Why do we need to do RF testing?
- Engineers, please take your seats. Keysight's metrology experts will give a lecture on electronic instrument metrology calibration knowledge and calibration cycle.
- What kind of circuit is this? Does anyone know how to analyze it?
- TMS320C5509A Study Notes - Pre-study Notes
- Could you help me check if this sentence is translated correctly?
- Msp430f149 programming interrupt processing function
- Python Notes for Professionals book
- Design of low voltage SRAM unit circuit based on 28nm process
- ~\(≧▽≦)/~A new board just arrived today, you know~