EXP 2 MA PRACTICAL

ALP to blink LEDs connected to port P1 with 1ms delay
ORG 0000H ;start
SJMP MAIN
ORG 0045H
MAIN:MOV A,#0FFH ;to turn ON all LEDs
BACK:MOV P1,A ;LEDs are connected to port P1 so copy data from A to P1
ACALL DELAY
CPL A ;to turn OFF all LEDs
SJMP BACK

DELAY:MOV R2,#02H ;delay
GO:MOV R3,#0FFH
AGAIN:DJNZ R3,AGAIN
DJNZ R2,GO
RET
END

ALP to toggle LEDs connected to port P1 with 1ms delay
ORG 0000H ;start
SJMP MAIN
ORG 0045H
MAIN:MOV A,#0AAH ;to turn ON odd and even LEDs alternately
BACK:MOV P1,A
ACALL DELAY ;to call delay
CPL A
SJMP BACK

DELAY:MOV R2,#02H ;delay
GO:MOV R3,#0FFH
AGAIN:DJNZ R3,AGAIN
DJNZ R2,GO
RET
END

ALP to blink group of 4 LEDs alternately connected to port P1 with 1ms delay
ORG 0000H ;start
SJMP MAIN
ORG 0045H
MAIN:MOV A,#0FH ;to turn ON LEDs of lower nibble
BACK:MOV P1,A
ACALL DELAY ;to call delay
CPL A ;to turn ON LEDs of upper nibble
SJMP BACK

DELAY:MOV R2,#02H ;delay
GO:MOV R3,#0FFH
AGAIN:DJNZ R3,AGAIN
DJNZ R2,GO
RET
END

ALP to chase LEDs from left to right
ORG 0000H ;start
SJMP MAIN
ORG 0045H
MAIN:MOV A,#01H ;to turn ON first LED
BACK:MOV P1,A
ACALL DELAY ;to call delay
RL A ;to turn ON next LED
SJMP BACK

DELAY:MOV R2,#02H ;delay
GO:MOV R3,#0FFH
AGAIN:DJNZ R3,AGAIN
DJNZ R2,GO
RET
END

ALP to blink LED connected at P1.3
ORG 0000H ;start
SJMP MAIN
ORG 0045H
MAIN:SETB P1.3 ;to turn ON LED at P1.3
ACALL DELAY ;to call delay of 1ms
CPL P1.3 ;to turn OFF LED at P1.3
SJMP MAIN

DELAY:MOV R2,#02H ;delay
GO:MOV R3,#0FFH
AGAIN:DJNZ R3,AGAIN
DJNZ R2,GO
RET
END
Previous Post Next Post