Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views2 pages

Dhynesh J - 715522243017

The document outlines an 8051 assembly program to create a left-to-right LED chaser effect on Port 2 using logical shifts. It includes an algorithm for initialization, outputting bits, and a delay function to control the timing of the LED transitions. The program continuously shifts the output until it exceeds a certain value, at which point it resets to the starting position.

Uploaded by

22d104
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Dhynesh J - 715522243017

The document outlines an 8051 assembly program to create a left-to-right LED chaser effect on Port 2 using logical shifts. It includes an algorithm for initialization, outputting bits, and a delay function to control the timing of the LED transitions. The program continuously shifts the output until it exceeds a certain value, at which point it resets to the starting position.

Uploaded by

22d104
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Dhynesh J - 715522243017

Write an 8051 program to create a left-to-right LED


chaser effect on Port 2 using logical shift
Algorithm:
1. Initialize the microcontroller.
2. Set Port 2 as output.
3. Start with the leftmost bit (0x01).
4. Output this bit to Port 2.
5. Wait using a delay.
6. Perform a logical left shift (i.e., << 1).
7. If the shifted value exceeds 0x80, reset it to 0x01.
8. Repeat the process infinitely.

Delay function:
1. MOV R7, #100 ; Outer loop count (adjust for longer delay)
2. OUTER_LOOP:
3. MOV R6, #200 ; Inner loop count (adjust for fine-tuning delay)
4. INNER_LOOP:
5. DJNZ R6, INNER_LOOP ; Decrement R6 until zero
6. DJNZ R7, OUTER_LOOP ; Decrement R7, repeat outer loop if not zero
7. RET.

Program:
ORG 0000H ; Start of the program
MOV P2, #00H ; Clear Port 2
MOV A, #01H ; Start with first LED ON

MAIN:
MOV P2, A ; Output to Port 2
ACALL DELAY ; Call delay
RL A ; Logical Left Shift (Rotate Left through Carry)
CJNE A, #00H, NEXT
MOV A, #01H ; Reset to first LED if all shifted out

NEXT:
SJMP MAIN ; Repeat forever

; Delay routine
DELAY:
MOV R2, #255
MOV R3, #255
D1: DJNZ R3, D1
DJNZ R2, D1
RET

OUTPUT:

You might also like