//Example 19: Use if statement to control the flow direction of 8-bit LED of port P0
#include
sbit K5=P1^4; //Define S1 as P1.4
sbit K6=P1^5; //Define S2 as P1.5
/*****************************
Function: Main function
********************************/
void main(void)
{
while(1)
{
if(K5==0) //If button S1 is pressed
P0=0x0f; //The high four-bit LED of port P0 lights up
if(K6==0) //If button S2 is pressed
P0=0xf0; //The low four-bit LED of port P0 lights up
}
}
Previous article:Controlling LED Lights with Character Arrays
Next article:Using array pointer to control LED running lights -- C language programming
- Popular Resources
- Popular amplifiers
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
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- 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
- TI DSP C6657 Learning - Compiling static library .lib
- tree Command
- What are the categories of edge computing devices?
- How to make a simple calculator using STM8L151K4
- A question about transformers
- Application skills of watchdog reset
- Anyone know what connector this is?
- [Evaluation of the popular N32G45XVL model of the National Technology M4 core] Part 6 Preparation for motor application development
- AR1021X uses hostapd to configure AP hotspots.
- Design method of adding soft start to DCDC chip