1. Experimental topic:
A three-machine fault detection and indication system is simulated in Proteus, as shown in Figure 2. When there is no fault, LED0 is on; when there is a fault, LED0 is off. When fault 1 (P2.0 is 0), LED1 is on; when fault 2 (P2.1 is 0), LED1 is on; when fault 3 (P2.2 is 0), LED3 is on.
2.KEIL code
#include sbit LED=P1^0; sbit LED1=P1^1; sbit LED2=P1^2; sbit LED3=P1^3; sbit P20=P2^0; sbit P21=P2^1; sbit P22=P2^2; void INT0_Init() //Write interrupt initialization function { EA=1; //Turn on the interrupt master switch EX0=1; // Enable external interrupt 1 IT0=1; //Set to falling edge trigger } void main() { INT0_Heat(); while (1) { if(P20==1&&P21==1&&P22==1) {LED=0;LED1=1;LED2=1;LED3=1;} else LED=1; } } void INT0_Rupt() interrupt 0 //Write external interrupt 0 service function { LED1=P20; LED2=P21; LED3=P22; } 3. Protues simulation diagram When no button is pressed, the LED is on: When button 2 is pressed, LED goes out and LED2 turns on.
Previous article:51 MCU experiment - Use timer 0 to realize the running light, requiring each LED to display for 1s in turn
Next article:51 MCU Experiment - Using External Key Interrupt to Implement Quaternary Counter
- Popular Resources
- Popular amplifiers
- Learn ARM development(19)
- Learn ARM development(14)
- 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)
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(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
- 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?
- [Domestic RISC-V Linux board Fang·Starlight VisionFive trial report] C language programming to control WS2812B colorful lamp beads
- The AD voltage check has been completed, how to connect it to the LED
- Mechanical and electrical system testing and control from entry to mastery
- I would like to ask a question about LCD power supply circuit.
- Tektronix TDS7254 Oscilloscope Trigger Failure Repair Case
- DSP28335 ADC software trigger
- Integrated power devices simplify FPGA and SoC design
- Tutorial on connecting STM32F407 Explorer Development Board to Gizwits Cloud
- Pingtouge recommends adding a keyword input matching function when selecting tags for blog posts
- Share a book suitable for C language beginners