Code Led băng LED1 BIT P0.0; LED2 BIT P0.1; LED3 BIT P0.2; LED4 BIT P0.3; LED5 BIT P0.4; LED6 BIT P0.5; LED7 BIT P0.6; LED8 BIT P0.7; LED9 BIT P2.7; LED10 BIT P2.6; LED11 BIT P2.5; LED12 BIT P2.4; LED13 BIT P2.3; LED14 BIT P2.2; LED15 BIT P2.1; LED16 BIT P2.0; CUONGDO EQU ; CUONG DO SANG LED , CANG NHO CANG SANG ; -ORG 0000H JMP MAIN ;###################### HAM MAIN ##################################################### ORG 0030H MAIN: MOV P0,#0FFH MOV P2,#0FFH ;################################################################### START: mov r0,#10 LCALL HIEU_UNG_17 mov r0,#10 LCALL HIEU_UNG_18 mov r0,#10 LCALL HIEU_UNG_19 mov r0,#10 LCALL HIEU_UNG_20 mov r0,#10 LCALL HIEU_UNG_21 mov r0,#10 LCALL HIEU_UNG_22 mov r0,#10 LCALL HIEU_UNG_23 mov r0,#10 LCALL HIEU_UNG_24 mov r0,#10 LCALL HIEU_UNG_25 mov r0,#10 LCALL HIEU_UNG_26 mov r0,#10 LCALL HIEU_UNG_27 mov r0,#10 LCALL HIEU_UNG_28 mov r0,#10 LCALL HIEU_UNG_29 mov r0,#10 LCALL HIEU_UNG_30 mov r0,#10 LCALL HIEU_UNG_31 mov r0,#10 LCALL HIEU_UNG_1 mov r0,#10 LCALL HIEU_UNG_2 mov r0,#10 LCALL HIEU_UNG_3 mov r0,#10 LCALL HIEU_UNG_4 mov r0,#10 LCALL HIEU_UNG_5 mov r0,#10 LCALL HIEU_UNG_6 mov r0,#10 LCALL HIEU_UNG_7 mov r0,#10 LCALL HIEU_UNG_8 mov r0,#10 LCALL HIEU_UNG_9 mov r0,#10 LCALL HIEU_UNG_10 mov r0,#10 LCALL HIEU_UNG_11 mov r0,#10 LCALL HIEU_UNG_12 mov r0,#10 LCALL HIEU_UNG_13 mov r0,#10 LCALL HIEU_UNG_14 mov r0,#10 LCALL HIEU_UNG_15 mov r0,#10 LCALL HIEU_UNG_16 LJMP START ;############## CHƯƠNG TRÌNH ##################### HIEU_UNG_1: MOV P0,#0FFH MOV P2,#0FFH MOV TIME_NUM,#CUONGDO LCALL delayUs LCALL HU1 DJNZ R0,HIEU_UNG_1 RET HU1: CLR LED1 MOV TIME_NUM,#1 LCALL delayUs CLR LED2 MOV TIME_NUM,#1 LCALL delayUs CLR LED3 MOV TIME_NUM,#1 LCALL delayUs CLR LED4 MOV TIME_NUM,#1 LCALL delayUs CLR LED5 MOV TIME_NUM,#1 LCALL delayUs CLR LED6 MOV TIME_NUM,#1 LCALL delayUs CLR LED7 MOV TIME_NUM,#1 LCALL delayUs CLR LED8 MOV TIME_NUM,#1 LCALL delayUs CLR LED9 MOV TIME_NUM,#1 LCALL delayUs CLR LED10 MOV TIME_NUM,#1 LCALL delayUs CLR LED11 MOV TIME_NUM,#1 LCALL delayUs CLR LED12 MOV TIME_NUM,#1 LCALL delayUs CLR LED13 MOV TIME_NUM,#1 LCALL delayUs CLR LED14 MOV TIME_NUM,#1 LCALL delayUs CLR LED15 MOV TIME_NUM,#1 LCALL delayUs CLR LED16 MOV TIME_NUM,#1 LCALL delayUs RET ;######################################################################################### HIEU_UNG_2: MOV P0,#0FFH MOV P2,#0FFH MOV TIME_NUM,#CUONGDO LCALL delayUs MOV TIME_NUM,#1 LCALL delayUs LCALL HU2 DJNZ R0,HIEU_UNG_2 RET HU2: CLR LED1 MOV TIME_NUM,#1 LCALL delayUs CLR LED2 MOV TIME_NUM,#1 LCALL delayUs CLR LED3 MOV TIME_NUM,#1 LCALL delayUs CLR LED4 MOV TIME_NUM,#1 LCALL delayUs CLR LED5 MOV TIME_NUM,#1 LCALL delayUs CLR LED6 MOV TIME_NUM,#1 LCALL delayUs CLR LED7 MOV TIME_NUM,#1 LCALL delayUs CLR LED8 MOV TIME_NUM,#1 LCALL delayUs CLR LED9 MOV TIME_NUM,#1 LCALL delayUs CLR LED10 MOV TIME_NUM,#1 LCALL delayUs CLR LED11 MOV TIME_NUM,#1 LCALL delayUs CLR LED12 MOV TIME_NUM,#1 LCALL delayUs CLR LED13 MOV TIME_NUM,#1 LCALL delayUs CLR LED14 MOV TIME_NUM,#1 LCALL delayUs CLR LED15 MOV TIME_NUM,#1 LCALL delayUs RET ;######################################################################################### HIEU_UNG_3: MOV P0,#0FFH MOV P2,#0FFH MOV TIME_NUM,#CUONGDO LCALL delayUs LCALL HU3 DJNZ R0,HIEU_UNG_3 RET HU3: MOV TIME_NUM,#2 LCALL delayUs CLR LED1 MOV TIME_NUM,#1 LCALL delayUs CLR LED2 MOV TIME_NUM,#1 LCALL delayUs CLR LED3 MOV TIME_NUM,#1 LCALL delayUs CLR LED4 MOV TIME_NUM,#1 LCALL delayUs CLR LED5 MOV TIME_NUM,#1 LCALL delayUs CLR LED6 MOV TIME_NUM,#1 LCALL delayUs CLR LED7 MOV TIME_NUM,#1 LCALL delayUs CLR LED8 MOV TIME_NUM,#1 LCALL delayUs CLR LED9 MOV TIME_NUM,#1 LCALL delayUs CLR LED10 MOV TIME_NUM,#1 LCALL delayUs CLR LED11 MOV TIME_NUM,#1 LCALL delayUs CLR LED12 MOV TIME_NUM,#1 LCALL delayUs CLR LED13 MOV TIME_NUM,#1 LCALL delayUs CLR LED14 MOV TIME_NUM,#1 LCALL delayUs RET ;######################################################################################### HIEU_UNG_4: MOV P0,#0FFH MOV P2,#0FFH MOV TIME_NUM,#CUONGDO LCALL delayUs MOV TIME_NUM,#3 LCALL delayUs CLR LED1 MOV TIME_NUM,#1 LCALL delayUs CLR LED2 MOV TIME_NUM,#1 LCALL delayUs CLR LED3 MOV TIME_NUM,#1 LCALL delayUs CLR LED4 MOV TIME_NUM,#1 LCALL delayUs CLR LED5 MOV TIME_NUM,#1 LCALL delayUs CLR LED6 MOV TIME_NUM,#1 LCALL delayUs CLR LED7 MOV TIME_NUM,#1 LCALL delayUs CLR LED8 MOV TIME_NUM,#1 LCALL delayUs CLR LED9 MOV TIME_NUM,#1 LCALL delayUs CLR LED10 MOV TIME_NUM,#1 LCALL delayUs CLR LED11 MOV TIME_NUM,#1 LCALL delayUs CLR LED12 MOV TIME_NUM,#1 LCALL delayUs CLR LED13 MOV TIME_NUM,#1 LCALL delayUs DJNZ R0,HIEU_UNG_4 RET ;######################################################################################### HIEU_UNG_5: MOV P0,#0FFH MOV P2,#0FFH MOV TIME_NUM,#CUONGDO LCALL delayUs MOV TIME_NUM,#4 LCALL delayUs CLR LED1 MOV TIME_NUM,#1 LCALL delayUs CLR LED2 MOV TIME_NUM,#1 LCALL delayUs CLR LED3 MOV TIME_NUM,#1 LCALL delayUs CLR LED4 MOV TIME_NUM,#1 LCALL delayUs CLR LED5 MOV TIME_NUM,#1 LCALL delayUs CLR LED6 MOV TIME_NUM,#1 LCALL delayUs CLR LED7 MOV TIME_NUM,#1 LCALL delayUs CLR LED8 MOV TIME_NUM,#1 LCALL delayUs CLR LED9 MOV TIME_NUM,#1 LCALL delayUs CLR LED10 MOV TIME_NUM,#1 LCALL delayUs CLR LED11 MOV TIME_NUM,#1 LCALL delayUs CLR LED12 MOV TIME_NUM,#1 LCALL delayUs DJNZ R0,HIEU_UNG_5 ;============HIEU UNG 13 HIEU_UNG_13: MOV P0,#0FFH MOV P2,#0FFH MOV TIME_NUM,#CUONGDO LCALL delayUs MOV TIME_NUM,#12 LCALL delayUs CLR LED1 MOV TIME_NUM,#1 LCALL delayUs CLR LED2 MOV TIME_NUM,#1 LCALL delayUs CLR LED3 MOV TIME_NUM,#1 LCALL delayUs CLR LED4 MOV TIME_NUM,#1 LCALL delayUs DJNZ R0,HIEU_UNG_13 RET ; 14 HIEU_UNG_14: MOV P0,#0FFH MOV P2,#0FFH MOV TIME_NUM,#CUONGDO LCALL delayUs MOV TIME_NUM,#13 LCALL delayUs CLR LED1 MOV TIME_NUM,#1 LCALL delayUs CLR LED2 MOV TIME_NUM,#1 LCALL delayUs CLR LED3 MOV TIME_NUM,#1 LCALL delayUs DJNZ R0,HIEU_UNG_14 RET ;=============hd 15 HIEU_UNG_15: MOV P0,#0FFH MOV P2,#0FFH MOV TIME_NUM,#CUONGDO LCALL delayUs MOV TIME_NUM,#14 LCALL delayUs CLR LED1 MOV TIME_NUM,#1 LCALL delayUs CLR LED2 MOV TIME_NUM,#1 LCALL delayUs DJNZ R0,HIEU_UNG_15 RET ; -HIEU UNG 16 HIEU_UNG_16: MOV P0,#0FFH MOV P2,#0FFH MOV TIME_NUM,#CUONGDO LCALL delayUs MOV TIME_NUM,#15 LCALL delayUs CLR LED1 MOV TIME_NUM,#1 LCALL delayUs DJNZ R0,HIEU_UNG_16 RET ;=============== HIEU_UNG_17: MOV P0,#0FFH MOV P2,#0FFH MOV TIME_NUM,#CUONGDO LCALL delayUs CLR LED16 MOV TIME_NUM,#16 LCALL delayUs DJNZ R0,HIEU_UNG_17 RET ;=============== HIEU_UNG_18: MOV P0,#0FFH MOV P2,#0FFH MOV TIME_NUM,#CUONGDO LCALL delayUs CLR LED15 MOV TIME_NUM,#1 LCALL delayUs CLR LED16 MOV TIME_NUM,#15 LCALL delayUs DJNZ R0,HIEU_UNG_18 RET ;=============== HIEU_UNG_19: MOV P0,#0FFH MOV P2,#0FFH MOV TIME_NUM,#CUONGDO LCALL delayUs CLR LED14 MOV TIME_NUM,#1 LCALL delayUs CLR LED15 MOV TIME_NUM,#1 LCALL delayUs CLR LED16 MOV TIME_NUM,#14 LCALL delayUs DJNZ R0,HIEU_UNG_19 RET ;=============== ;=============== HIEU_UNG_20: MOV P0,#0FFH MOV P2,#0FFH MOV TIME_NUM,#CUONGDO LCALL delayUs CLR LED13 MOV TIME_NUM,#1 LCALL delayUs CLR LED14 MOV TIME_NUM,#1 LCALL delayUs CLR LED15 MOV TIME_NUM,#1 LCALL delayUs CLR LED16 MOV TIME_NUM,#13 LCALL delayUs DJNZ R0,HIEU_UNG_20 RET ;======== HIEU_UNG_21: MOV P0,#0FFH MOV P2,#0FFH MOV TIME_NUM,#CUONGDO LCALL delayUs CLR LED12 MOV TIME_NUM,#1 LCALL delayUs CLR LED13 MOV TIME_NUM,#1 LCALL delayUs CLR LED14 MOV TIME_NUM,#1 LCALL delayUs CLR LED15 MOV TIME_NUM,#1 LCALL delayUs CLR LED16 MOV TIME_NUM,#11 LCALL delayUs DJNZ R0,HIEU_UNG_21 RET ;========================= ;======== HIEU_UNG_22: MOV P0,#0FFH MOV P2,#0FFH MOV TIME_NUM,#CUONGDO LCALL delayUs CLR LED11 MOV TIME_NUM,#1 LCALL delayUs CLR LED12 MOV TIME_NUM,#1 LCALL delayUs CLR LED13 MOV TIME_NUM,#1 LCALL delayUs CLR LED14 MOV TIME_NUM,#1 LCALL delayUs CLR LED15 MOV TIME_NUM,#1 LCALL delayUs CLR LED16 MOV TIME_NUM,#10 LCALL delayUs DJNZ R0,HIEU_UNG_22 RET ;========================= HIEU_UNG_23: MOV P0,#0FFH MOV P2,#0FFH MOV TIME_NUM,#CUONGDO LCALL delayUs CLR LED10 MOV TIME_NUM,#1 LCALL delayUs CLR LED11 MOV TIME_NUM,#1 LCALL delayUs CLR LED12 MOV TIME_NUM,#1 LCALL delayUs CLR LED13 MOV TIME_NUM,#1 LCALL delayUs CLR LED14 MOV TIME_NUM,#1 LCALL delayUs CLR LED15 MOV TIME_NUM,#1 LCALL delayUs CLR LED16 MOV TIME_NUM,#9 LCALL delayUs DJNZ R0,HIEU_UNG_23 RET ;========================= HIEU_UNG_24: MOV P0,#0FFH MOV P2,#0FFH MOV TIME_NUM,#CUONGDO LCALL delayUs CLR LED9 MOV TIME_NUM,#1 LCALL delayUs CLR LED10 MOV TIME_NUM,#1 LCALL delayUs CLR LED11 MOV TIME_NUM,#1 LCALL delayUs CLR LED12 MOV TIME_NUM,#1 LCALL delayUs CLR LED13 MOV TIME_NUM,#1 LCALL delayUs CLR LED14 MOV TIME_NUM,#1 LCALL delayUs CLR LED15 MOV TIME_NUM,#1 LCALL delayUs CLR LED16 MOV TIME_NUM,#8 LCALL delayUs DJNZ R0,HIEU_UNG_24 RET ;================= ;========================= HIEU_UNG_25: MOV P0,#0FFH MOV P2,#0FFH MOV TIME_NUM,#CUONGDO LCALL delayUs CLR LED8 MOV TIME_NUM,#1 LCALL delayUs CLR LED9 MOV TIME_NUM,#1 LCALL delayUs CLR LED10 MOV TIME_NUM,#1 LCALL delayUs CLR LED11 MOV TIME_NUM,#1 LCALL delayUs CLR LED12 MOV TIME_NUM,#1 LCALL delayUs CLR LED13 MOV TIME_NUM,#1 LCALL delayUs CLR LED14 MOV TIME_NUM,#1 LCALL delayUs CLR LED15 MOV TIME_NUM,#1 LCALL delayUs CLR LED16 MOV TIME_NUM,#7 LCALL delayUs DJNZ R0,HIEU_UNG_25 RET ;============================================ HIEU_UNG_26: MOV P0,#0FFH MOV P2,#0FFH MOV TIME_NUM,#CUONGDO LCALL delayUs CLR LED7 MOV TIME_NUM,#1 LCALL delayUs CLR LED8 MOV TIME_NUM,#1 LCALL delayUs CLR LED9 MOV TIME_NUM,#1 LCALL delayUs CLR LED10 MOV TIME_NUM,#1 LCALL delayUs CLR LED11 MOV TIME_NUM,#1 LCALL delayUs CLR LED12 MOV TIME_NUM,#1 LCALL delayUs ... R0,HIEU_UNG_1 RET HU1: CLR LED1 MOV TIME_NUM,#1 LCALL delayUs CLR LED2 MOV TIME_NUM,#1 LCALL delayUs CLR LED3 MOV TIME_NUM,#1 LCALL delayUs CLR LED4 MOV TIME_NUM,#1 LCALL delayUs CLR LED5 MOV TIME_NUM,#1... LCALL delayUs CLR LED6 MOV TIME_NUM,#1 LCALL delayUs CLR LED7 MOV TIME_NUM,#1 LCALL delayUs CLR LED8 MOV TIME_NUM,#1 LCALL delayUs CLR LED9 MOV TIME_NUM,#1 LCALL delayUs CLR LED1 0 MOV TIME_NUM,#1... LCALL delayUs CLR LED1 1 MOV TIME_NUM,#1 LCALL delayUs CLR LED1 2 MOV TIME_NUM,#1 LCALL delayUs CLR LED1 3 MOV TIME_NUM,#1 LCALL delayUs CLR LED1 4 MOV TIME_NUM,#1 LCALL delayUs CLR LED1 5 MOV TIME_NUM,#1