Ex 11 LED Blinking
Ex 11 LED Blinking
No : 11 LED BLINKING
AIM
Procedure
Code
SETB P2.0 ; Set Port 2, Pin 0 (P2.0) high (turn LED on)
BLINK: CPL P2.0 ; Toggle the state of P2.0 (turn LED on/off)
LCALL DELAY ; Call the delay subroutine
SJMP BLINK ; Jump back to the BLINK label (create an infinite loop)
DELAY: MOV R7, #01H ; Load the value 0x01 into register R7 (outer loop
counter)
LOOP: MOV R6, #01H ; Load the value 0x01 into register R6 (inner loop
counter)
DJNZ R6, $ ; Decrement R6 and jump to the same instruction until R6
is zero (small delay)
DJNZ R7, LOOP; Decrement R7 and jump back to the LOOP label until R7 is
zero (larger delay)
RET ; Return from the delay subroutine to the main program
Steps to Execute
Explanation of Comments:
SJMP BLINK: Jumps back to the BLINK label, creating an infinite loop.
MOV R7, #01H: Loads 0x01 into R7 for the outer loop counter.
MOV R6, #01H: Loads 0x01 into R6 for the inner loop counter.
DJNZ R6, $: Decrements R6 and loops until R6 is zero, creating a small delay.
DJNZ R7, LOOP: Decrements R7 and loops back to the inner loop until R7 is zero, creating a larger delay.
Output
LED Panel