Function Call
If a function is written after the main function, the function must be declared before the main function.
Actual parameters: the parameters in the brackets when calling a function
Formal parameters: The function is defined when the function is called, and the parameters in the brackets are called formal parameters.
Key debounce: When a key is pressed, there will be jitter, and a delay of 10ms is required
#include
sbit ADDR0 = P1^0;
sbit ADDR1 = P1^1;
sbit ADDR2 = P1^2;
sbit ADDR3 = P1^3;
sbit ENLED = P1^4;
sbit KEY4 = P2^7;
unsigned char code LedChar[]={
0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8,
0x80, 0x90, 0x88, 0x83, 0xC6, 0xA1, 0x86, 0x8E
};
bit KeySta = 1;
void main()
{
bit backup = 1;
unsigned char cnt = 0;
EA = 1;
ENLED = 0;
ADDR3 = 1;
ADDR2 = 0;
ADDR1 = 0;
ADDR0 = 0;
TMOD = 0x01;
TH0 = 0xF8;
TL0 = 0xCD;
ET0 = 1;
TR0 = 1;
P2 = 0xF7;
P0 = LedChar[cnt];
while(1)
{
if(KeySta != backup)
{
if(backup == 0)
{
cnt++;
if(cnt >= 10)
{
cnt = 0;
}
P0 = LedChar[cnt];
}
backup = KeySta;
}
}
}
void InterruptTimer0() interrupt 1
{
static unsigned char keybuf = 0xFF;
TH0 = 0xF8;
TL0 = 0xCD;
keybuf = (keybuf <<1) |KEY4;
if(keybuf == 0x00)
{
KeySta = 0;
}
else if(keybuf == 0xFF)
{
KeySta = 1;
}
else
{
}
}
Previous article:Stepper motor and buzzer
Next article:[51 MCU] Matrix keyboard line-by-line scanning simulation experiment + ultra-detailed Proteus simulation and Keil operation steps
- Popular Resources
- Popular amplifiers
- 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)
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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- 【phyBOARD-i.MX 8M Plus Development Board】Review 1: Hardware Analysis
- What are the shortcomings of smart homes? How to solve these problems?
- IGBT drive and protection circuit design and application circuit examples (2nd edition)
- The development of smartphones
- [Atria AT32WB415 series Bluetooth BLE 5.0 MCU] Light up in FreeRTOS, all codes, Github long-term update
- OSAL operating system issues
- Want to get better service? TE customer service said: "I can"
- Is the '*' symbol in Verilog considered a multiplier?
- 【Qinheng RISC-V core CH582】Evaluation summary
- Cache Coherence