Interrupt-key control LED status, key led status
Program function: press the button to control the LED status and interrupt the implementation.
Symptom: When you press the k key, LED0 will always flash, thus affecting other LEDs.
Note: Use the Dupont wire to connect the P3.2 pin (INT0) to the switch K pin.
Program:
ORG 0000 h ljmp main org 0003 H; External Interrupt 0 entry LJMP INT0 ORG 0200 HMAIN: setb ea; enable total interrupt SETB EX0; enable external interrupt 0, that is, the CLR IT0 on the P3.2 pin; set it to the low-level trigger mode SJMP $; the main program only waits for the interruption INT0: DEC P1; the external interrupt 0 interrupt response, the content of the P1 port is reduced by 1 lcall delay; call the DELAY subroutine RETI; return DELAY: MOV R5, #255; latency subroutine D1: MOV R6, #255 DJNZ R6, $ DJNZ R5, D1 RET END