P2.0~P2.2 are connected with independent keys K0, K1, and K2, respectively.
P1 is connected to 8 LEDs and emits light when the output is low.
Claim:
Press the K1 key and P1.7 outputs a square wave with a period of 1s;
Press K2 key, P1 output circulating water light, every 2 lights light 0.5s;
Press the K0 key to stop the square wave and water lamp output.
;-----------------------------------------
;
ORG 0000H
JMP START
ORG 000BH
; JMP T0_INT
T0_INT:
MOV TH0, #(65536 - 50000) / 256
MOV TL0, #(65536 - 50000) MOD 256
DJNZ R2, T0_END
MOV R2, #10
JNB F0, T0_2
ORL P1, #127
CPL P1.7
T0_END:
RETI
T0_2:
RL A
MOV P1, A
RETI
;-----------------------------------------
START:
MOV TMOD, #01H
MOV TH0, #(65536 - 50000) / 256
MOV TL0, #(65536 - 50000) MOD 256
MOV IE, #82H
MOV A, #63
MOV R2, #10
SETB TR0
K1:
JB P2.1, K2
SETB F0
SETB TR0
K2:
JB P2.2, K0
CLR F0
SETB TR0
K0:
JB P2.0, K1
CLR TR0
SJMP K1
END
;-----------------------------------------
Shenzhen Scodeno Technology Co.,Ltd , https://www.scodenonet.com