Code vi xử lý đây!
PROCESSOR 16F877A
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC & _WRT_OFF & _LVP_OFF & _CPD_OFF
#INCLUDE <P16F877A.INC>
DEM1 EQU 20H
DEM2 EQU 21H
ORG 0000H
BCF STATUS,5
BCF STATUS,6
CLRF PORTB
CLRF PORTC
CLRF PORTD
BSF STATUS,5
CLRF TRISB
CLRF TRISC
CLRF TRISD
BCF STATUS,5
MAIN
MOVLW B'11111100'
MOVWF PORTC
MOVLW B'11111110'
MOVWF PORTB
CALL DELAY
MOVLW B'11111100'
MOVWF PORTC
MOVLW B'11111101'
MOVWF PORTB
CALL DELAY
MOVLW B'00000000'
MOVWF PORTC
MOVLW B'11111011'
MOVWF PORTB
CALL DELAY
MOVLW B'00000000'
MOVWF PORTC
MOVLW B'11110111'
MOVWF PORTB
CALL DELAY
MOVLW B'00000000'
MOVWF PORTC
MOVLW B'11101111'
MOVWF PORTB
CALL DELAY
MOVLW B'11111100'
MOVWF PORTC
MOVLW B'11011111'
MOVWF PORTB
CALL DELAY
MOVLW B'11111100'
MOVWF PORTC
MOVLW B'10111111'
MOVWF PORTB
CALL DELAY
MOVLW B'11111111'
MOVWF PORTC
MOVLW B'11111111'
MOVWF PORTB
CALL DELAY
MOVLW B'01111111'
MOVWF PORTD
MOVLW B'00110011'
MOVWF PORTC
CALL DELAY
MOVLW B'10111111'
MOVWF PORTD
MOVLW B'00100001'
MOVWF PORTC
CALL DELAY
MOVLW B'11011111'
MOVWF PORTD
MOVLW B'00100100'
MOVWF PORTC
CALL DELAY
MOVLW B'11101111'
MOVWF PORTD
MOVLW B'00100100'
MOVWF PORTC
CALL DELAY
MOVLW B'11110111'
MOVWF PORTD
MOVLW B'00100100'
MOVWF PORTC
CALL DELAY
MOVLW B'11111011'
MOVWF PORTD
MOVLW B'00000100'
MOVWF PORTC
CALL DELAY
MOVLW B'11111101'
MOVWF PORTD
MOVLW B'10001100'
MOVWF PORTC
CALL DELAY
MOVLW B'11111111'
MOVWF PORTD
MOVLW B'11111111'
MOVWF PORTC
CALL DELAY
GOTO MAIN
DELAY
BSF STATUS,5
MOVLW B'0000'
MOVWF OPTION_REG
BCF STATUS,5
MOVLW D'25'
MOVWF DEM1
BATDAU
MOVLW D'230'
MOVWF TMR0
BSF STATUS,5
BCF OPTION_REG,5
BCF STATUS,5
LOOP
BTFSS INTCON,2
GOTO LOOP
BCF INTCON,2
DECFSZ DEM1,1
GOTO BATDAU
RETURN
END
do gấp quá nên chưa vẽ hình..sr hen
Trả lờiXóa